fixed bugs in python wrapper