bug fixes in fit_coords and match_cats (mostly logical errors)