Tentative interface

The exported functions are tentatively the interface for other packages to use.  I've left a lot of TODOs / questions in the file, so please comment away.
Better to have it be a typedef and meet a proper interface, than have to change it all later