Added while codegen, fixed embedded if/factor statements