Revert "Merge pull request #37 from ankel/master"

This reverts commit 9115d8dce084c9b73398493e728099ea79f9480c, reversing
changes made to d2eee3c745c7deb3c7c4297f00990e601fc07cfa.

The pull request that was recently merged does not pass several unit tests and is not commented or documented in any way to describe the changes. I strongly suggest that we revert to the previous code until all unit tests pass.