Extracted EncodingPreference and minor refactors