This fixes a critical bug which occurs if editing is enabled, disabled and enabled again. Since line 16 checks for existence of marker group reference, markers never get reinitiated, causing the handler to use the old ones, which may have been changed in the last editing session.
This commit fixes couple bugs. One of them is polylines (or polygons) can be reduced to a single point by clicking on markers to remove them. Second, if an edge point is clicked for a polyline (not applicable to polygons since they are a circular linked list) code produces a js error since previous or next might not be present.