more basic refactorization
Merge pull request #28 from BillMills/master

more basic refactorization