cleanup code, add coap13 support