Wow! Joe that was fast reply.

I'm going to try your suggestion right now. The

ANSEL=%00000000 ' set all analog pins to digital

is what I think is the missing piece.
Will let know how this goes.
Thanks for your help.
Gordon