Just reorganizing the JS for better readability.