Major pull request

Code to DRY up stuff