Fixing up the connection to DB

Slight tweaks to probably break some stuff.