fix overwrite host support and make the code a bit more readable

Please review @DeepDiver1975 @schiesbn @PVince81 @mbiebl