cw.lua.in: move all top-level code together