some more refactoring, mostly in data.py