Fixed a number of minor issues with the SQL database.