Changed the logic of VariableByte Java version to match the C++ version