Some refactory on code and more documentation.
Merge pull request #157 from EasonLiao/review

code refactoring