CoAP refactoring