Some bug fixes

Fixed some issues, works fairly reliably now. Still needs some tweaking
on colour translations and the mode switching gestures.