Affinity Support

Changes and refactoring for affinity group support
Merge pull request #248 from andylyall/develop

Affinity Support