In the code-review branch...
The code burns 64 bytes at the final flashPointer = offset, but then adds 1024 to flashPointer before starting the search for the magic. Although the final page should have been erased, if the final offset is part way through the page, the search will start part way through the next page, unless it is rounded.