Import bugfix in data compatiblity check from Bill. See issue 1053.
Fix several bugs, implement multiple iterations