Switched to a monadic implementation for the runtime