Tested and fixed SQL statements.