Make a common function 'get_encoding_from_config' and refactor the code
Remove some unused configurations