Refactor encoding.rb, adding more methods