Refactored initial gesture code.

Improves clarity and compliance with coding standards.