Refactoring, Finished moving code to inside API