Merged code from zimcompare tool. Final coding in process.