DEV: Pythonic code improvement as per Tom's suggestions