Finished refactoring for hostmask support