Converted historyFix to dbIntegrityCheck, added image_ref updating