cw.lua.in: improve organization of code slightly