MonadSafeIO typeclass refactoring