Tidy up coodinate code