A lot of refactoring in an attempt to get a proper API package. Do not consider this done or safe at all - pushing so that saner men/women than I can critique it