clean up of code gen along with some documentation of the def format