Reimplemented according to changes in cwt-app project.