Fixes v1

Misc fixes. Mostly places where I think a different 'free' function should be called.