fixed centroid to be fractionally off consistent with the requested location

Also fixed a couple of stupid bugs.