Minor refactor of js files