Minor JavaScript and HTML refactor