more refactoring out parts
added C bindings

You need to link these with some extras when using gcc instead
of g++, -lm -lc -lstdc++ seem to be the keys.