Broke up the API code into a logical heirarchy for readability.