Implement PUT and PATCh and refactor other things slightly.