Some improvements in the python script