cwc: cleanups and better debug logging