Structuring the Synthesis of Heap-manipulating Programs