Began a massive refactor of the code

This refactor will make the library much more modular, and non-reliant
on client only code.