Improved and refactored preferences class