Fixed nomenclature bugs with sql queries.