how have you set FOSC for the pic.
there is no OSCCON REGISTER setting in your code , the CONFIG settings are not shown, unless you have a 4mz Xtal setup
how sure are you that FOSC is the 4mhz you think it is