Moved all keys.dat writing code into writeKeysFile in shared.py
Added backup copy creation during keys.dat write to prevent an accidental file loss due to the disk failure.
TImestamped the keys.dat backup file.
resolve merge conflict