Major refactorings to start preparing for a 0.1 api