Thank you people for your replies. Well turns out that the program wasn't getting stuck at certain points. Instead, the PIC was restarting on its own when it reaches a certain part of the code. The PIC is part of a board that controls a car robot. When the gas is pressed and the wheels start turning, the PIC automatically restarts, releasing the gas pedal (the program of this PIC starts with an order to release gas and hold for 20 seconds). Now the 5 volts for this board are obtained from the +5 V rail of the computer power supply on the car that is operating a motherboard. But yesterday I discovered that when I operate the board from a separate power supply, the problem doesn't happen and the PIC doesn't restart! Any ideas? The computer power supply seems to be working fine and the computer it is driving faces no problems at all. Could there be a problem with its 5V rail only?