merge refactor work back into master

1st pull request!