Some CoAP refactoring.