Fixed default database handling, closes #499