Refactored JavaScript into separate file.