Commit for safekeeping - query not yet working correctly, but I've made some interesting progress.