massive refactoring
Merge pull request #4 from zgao/master

massive refactoring