finish refactoring. time to redo relations.

cleanup query