Improved python wrapper