Some bugfixes for an empty database