Totally rewritten.
Merge pull request #3 from jhaoda/master

Totally rewritten.