Refactor so that API is accessed using service locator pattern.