Bugs 827969 & 827551 - gesture detector fixes

This started out as a fix for 827551 and in the process of fixing that, I found bug 827969 which is actually the more serious of the two bugs.  I know it is bad etiquette to combine the two fixes like this, but it is expedient to do it this way.