Fix X/Y swap

This code worked properly before the merge, but now it has the X and Y
co-ordinates the wrong way round. Fixing.