Fix bugs in StructureGenerator.