Removed deprecated methods.
Fixed resource leaks when an invalid encoding was passed
Merge remote-tracking branch 'gakuzzzz/hotfix_resource_leak'