rebuilt
refactoring, made a couple of things easier to follow
closes #31