Argh, MonadIO instance was leaking out.  Start to refactor, not finished yet.