More refactoring in ctnr.js