Fix stupid bug, add some Free functions
Simplify c library slightly