Fixed glaring errors.

The logic used in the set functions of the XY API was causing it to throw errors every time they were used.
Also fixed variables being incorrectly set.