Minor refactoring in api.
Started to refine the sample