misc cleanup
even filter
code gen refactored into class CodeGen