I think I may have traced the pass to my problem. I think what's been happening is that I have a header that I use to test the boards that is powered all the time. I think I'm applying 24V AC to the board with no ground and then grounding pin PORTB.7 then applying the ground to the chip. I have installed a resistor in the PORTB.7 line and have not seen the problem since then. I will keep checking though but so far so good.