Some more work on the API and CLI.
Also added some infrastructure for distribution/packaging.