Fixed some errors with AST code generation.

- Now supports closure variables
- Fixed problem with lambda functions in function_map