Idiomatic updates to python c bindings

Also potential fix for the corrupted memory