Further API refinement and demo code refactoring.