js/core.js, js/ct.js: refactoring and adding comments.