Updating encoding parameter in API and refactoring small changes in
implementation.