Significantly cleaned up editor code.