improved handling of database inconsistencies