pybind: Some fixes on semantics and code