Restructuring the API quite a bit, cleaning up, and fixing tests