various cleanup translator
fix function scoping in writer