Merge pull request #20 from djuretic/rewrite

Tests now passing