[bug 1045982] More fixes mentioned in bug.
[bug 1045982] JS cleanup.