Refactoring API code.