reformat code in ce.js, move all unused code to bottom of file