Cleaning up python code a little