small bug fixes to make the python and matlab codes more compatible