Refactoring to make Aegir more generic