Refactor

Superseeds GH-3

/cc @wingrunr21