Changed some MVars to IORef.