CodeMirror add and a few bugs fixed