Initial API draft

The implementation so far is a bit naive with a lot of
copying going on.