Add more comments on newly-added functions.
Add back opstate handler function.