The code is massive.

I have a 1hz led timer1 interrupt flasher routine.

It's only working at 1/4 speed with the 20mhz resonator but works correctly at 64mhz with the internal osc.