python. Cleaned up code generation, fixed #154, #153.