Refactoring to meet new API spec.