add stack pointer optimization, better constant folding and normalization