Below are the errors I found and corrected in the above sketch. The code runs ok now and hopefully contains no other errors.
Line 992 redefines global vector phantLog
Line 1604 incompatible with Line 1082 and 948
And yes, flash has been corrupted by the erratic program, in the link of previous post the discussion on tools for flash integrity assessment