Finished refactor of api
Finished testing and final refactor