Refactored some of the api loading, fixed lots of bugs