Cleaned up source code of queries