More JSCS checking and code refactoring