Added self.state to track recording state.