Refactor API code. For the better.