A simple and frankly obvious thing I tell my students all the time, is not to fixate too much on a bug being something you think it is..It may indeed be something totally different elsewhere causing a problem.
I've had such a bug myself, for quite some time now I've been trying to prevent a random speedup in the control system of my game which caused the main character to fly off screen when exiting rising or falling water. (It'll make sense later when you know the game.)
But try as a might, I could not work out exactly why the damn thing would sometimes fly off wildly at speed losing sync with the control system that keeps the character in a block range for collision checks.
So of course it had to be in the move routines...it had to be....or in the water routines....or in the key press readers, or or or
I hunted and hunted for this bug in all sorts of places, convinced it was something really complex that needed lots of hacking exception code to correct.
Well of course, it wasn't it was in the end blindingly obvious, I was using a flag to change between speeds and the fault was that I was doing it without checking if I was wholely on a block before altering speed, which meant the co-ord position of the character could bounce off a block and never get to check for a valid collision point..result...sometimes it flew of screen unable to detect the edge boundry blocks.
Ok not a blindingly obvious explination but the main point being I need to practice what I preach.... I will of course tell my students that I can be a bit of a dick sometimes...though not as often as they :).
On the upside a long standing and very demoralising bug has finally been crushed...onward.