Bug Fixes

Fixed bugs to make generated file validate.