Some Pythonic improvements