fix issue 223, beforeDetach not fired by jsPlumb
tidy up