first swipe at c rewrite
Merge pull request #14 from zinic/master

first swipe at c rewrite