Builder refactoring

Begins cleaning up the builder code in preparation of adding additional
functionality and also in preparation of breaking up into a package.