Huge refactoring of ast/msg.go.