Lots of updates and changes.

* Cleaning up the code mirror event handlers.
* Adding logic to prevent calling Notebook.command_mode on cell
  focusout.
* Fixing bugs.