Started work on pure c implementation. Should be sexier.