refactoring codeEditor a little; a few bug