enhance gesture implementation and globals management code