Fixed dragging handle remaining stucked until mouseleave

At the moment (on Chrome 29 at least) if you are dragging the handle and you release the mouse the handle stays there, not returning to one of the sides of the switch. It goes to the right position only on mouseleave.

The second commit fixes this issue, the other one is just simple refactoring and cleaning.