Refactored some js files.