mode code more pythonic

Just a couple of tiny fixes