It seems we're not that good in handling corrupted images, in particular if kID is missing in inventory file we get nil dereference thus fix it and clean up error path in check_img_inventory.