cw.c: simplify some code and improve an error message.