more bugfixes related to empty databases