Fixed a few problems related to connecting to the database