Fix reverse directions when wrapping around level edges.