Some code cleanup in base.py