Use new query system and delete unused variables/parameters