Fix crash in Next cop

This fixes #1191.

I'll rebase this once #1192 is merged.