Rework and fix CodeMirror file saving