more refactoring in addition to partial implementation of virtual host changing
forgot some stuff in last commit