Refactoring and api for hub.