Improve separation of concerns for API