Sorting out JavaScript so it's ready to go