Fixed encoding error caused by int->short conversion bug