Simplify some control flow structures in code generator