Alterations to attach/detach event listeners, added getMousePos (in the middle of working this out).