optimize readAttributes.py and the relevant part of Badger.py