Added minor changes to SQL query.