Corrected small mistakes in SQL generation