refactored to move normalization to codegen phase