Fixed using templates and split everything up. Had to change click and touchstart events to use document to find the item to handle.