Preventing double letter use in wrap mode, and ambiguity in coordinate_to_grid function when handling square matrices