Refactored some javascript involving track uploads