Fixed SQL queries.