Refactoring of coap.