bugfix: added the forth argument to update_ast; code refactoring.
code refactoring