Fixes to db connection