cwc: code cleanups and improvements for ECM handling

Some improvements for ECM handling