Added support for touch events via Hammer.js library and heavily cleaned up the code