cleaned up API. Several bug fixes. Added basic demo.