Refactored JS for readability. Added automatic loading messages per SRBALA's suggestion.