Rearranged the code generator to support if.

Also removed dependencies on lambda functions, so we now support GCC 4.4 again.