Moved ordinary functions from file ..-classes to ..-query and to new file.