Added jscs and tidied up the code