cleanup in core.py