Code-base cleanup

Reorganized the code and add a few excerpts in the README file for using
the api.