lazy imports and cleaning in preferences.py