Some minor refactorings
Some minor refactorings

There's just a bunch of repeated code that I'd like to see 'merged'. This is not perfect either, but it's a start.
saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt