Minor JavaScript refactorings