split Query and Statement

query != statement
cleanup type handlers, less mutable state