refactor, add wildcard domain matching
Fix a couple small bugs