Modularize the library

As we are starting to get quite large, it would be good to modularize the various types. To me it is a bit unclear what the best approach for namespaces would be though (since e.g. Name may be used in package metadata and also repository metadata).

I'm happy to get some ideas/input here!