Applied konstin's bugfix for an editor crash.