Did some refactoring
Merge pull request #9 from ellisong/master

Did some refactoring