Yes, I've also been able to successfully reproduce your success with this code on my machine. By doing a straight cut-and-replace with your code, I still get my annoying behavior. I expect that I have a misplaced bracket elsewhere. So far nothing looks out of place.
I hesitate to place the entire code as it is rather inelegant to say the least ...