db connection handling improvements