fixing corner cases in database setting

*TODO: handling of deactivated plugins...