Refactor util functions into its own object and API related stuff into APIClient.

Test Plan:
- Tested to make sure everything still works.