Fixed bug in rebuild_structure().