Some fixes regarding db connection.