Moved generation of code for expressions into separate function.