Fixed another bug with connecting to db.
Finally fixed the db thing.