Fix for preferences savedState crashing - not perfect