Added API CRUD for pairs, plus a bit of tidy up of code