Change query interface internal working to functional transformations

TODO: Fix specs