Refactored CoAP support and added logging.