massive refactoring in objects.py