refactored ASTGenerator
generate code after AST creatrion
fixed possible nullptr exceptions
cosmetics