fix bugs in py bindings