partial refactor of codemirror

codemirror modularized
and minor components