Rewrote Main.hs to use StateT instead of IORefs.