Avoids an exception if data in the db is inconsistent, this can occur with very old upgrades, adds a warning if this is the case.