Fix bot host sending and do some refactoring.