Basic port of Perl client API. Missing a couple of features yet.