some fixes for an ugly script
some fixes and add some comments to generated file