db connection bugfixes