Fix bugs in the previous/next highlight functions