Tidied edit functionality up.  Further refinement needed