did some query work
partially through refactoring references
misc changes