Use common _get_xy_coords for input processing.
Reworked to use common input+output management. Tidied for pep8.