Clean up usage of RefCell.
Move QState and TelnetCore (now TelnetDemux) to their own files.