Major Refactor

- major restructuring of code
- better handling of complex corner cases of pivoting
- query params rewrite
- es6ify
- smaller, more focused tests

Paired w @twokul on the ES6 stuff