Added undo and clear functionality. Moved all manipulation of pointArray into a consistent place.