Finishing up the AST code.

Made some simplificiations that will likely have to be changed later.