Cleaning up SQL queries.