Few important fixes and improvements, more to do.

Started type Clone() interface function to fix problem of reassigning
AST node types.