If you have a device that can react that fast to a power-on condition, you
might also consider disabling PWRT (power-up timer).

PWRT alone can introduce a power-up delay period of roughly 72mS before
any code can execute & set/clear outputs. Factor that in with normal start-
up times, and you can end up with a substantial delay period before you can
initialize everything properly.

I think the PBP config word defaults in most device header files have PWRT
enabled, but if your power supply comes up quickly, and you don't see erratic
behavior on power-up with PWRT disabled, that just might cure the problem.