Handling when codemirror instance isn't available

Also removed some extra code that was commented out and no longer needed