Fix crash on db open