Fix a bug where prev/next context is not always set