Refactor api and add comments.