Fixed even more SQL queries.