refactor code
improve some API comments