more refactoring of base.py