Refactored some JS.