cleanup and rewrite
Merge pull request #1 from codepo8/master

cleanup and rewrite