Fix a problem where gesture actions sometimes don't end correctly on iOS

WIP

Closes #52