Cleaned up calibration code and tested on Windows.   Appears to work in all builds.