Fixed empty database crashes