Move query to core

Seems to me it's part of core.