Fixes and improvements to structure genration code.