Banksel is a ready written Macro, so that's one solution - or just enter a single line setting the bit you need to change (check my tutorials for examples).
Like Eric has said, the PIC only have a very small stack size (8 calls only), if you do too many nested calls you run out of stack space and it crashes.
You need to drop your number of nested calls a LOT - because once you start using interrupts, you're going to hit much bigger problems.
For a simple to understand 'example', place eight coins on the table in front of you.
First pick a coin up, that's a 'call', now put it back, that's a 'return' - now pick two coins up (two nested calls), now pick six more up (six more nested calls) - now try and do another 'call' - no coins to pickup, and your fingers are bleeding on the table.
That's what crashes the PIC, it's little silicon fingers are bleeding on the table.