Refactored settings reading; more general.