Review and optimize generated python