refactored to support both per-host and per-group
whitespace cleanup