That chip has comparators that need turned off when not using them.
Try adding near the top of your code
CM1CON0 = 0
CM2CON0 = 0