Move all tap hacks code into a separate handler

Pull for #1781