Further refactored the self-hosted server behaviour.