I added a number of debugging outputs to help with checking the flash program output against hand calculations or verifying intermediate calculations steps. These are turned off by default but can be turned on at compile time setting the DEBUG definition to 1.
Add Debugging