Fixed some bugs, got code working with a wider set of coordinates.