Change types again, uses RWS monad and supports scopes