Encoding improvements. #117