minor refactorings in core.py