Fixed some raw type references. Introduced ASTNodeUtil to wrap certain
unsafe casts in as typesafe a manner as possible.