Refactored gesture code a little