Improved error handling in Settings class.