bugfixes in db handling