fix incomplete cloning of AST. add debug logs. delete unused code