Some api host refactoring.