final public int writeVarLong (long value, boolean optimizePositive) throws KryoException {
		if (!optimizePositive) value = (value << 1) ^ (value >> 63);
		int varInt = 0;

		varInt = (int)(value & 0x7F);

		value >>>= 7;

		if (value == 0) {
			writeByte(varInt);
			return 1;
		}

		varInt |= 0x80;
		varInt |= (value << 8);

		value >>>= 7;

		if (value == 0) {
			writeLittleEndianInt(varInt);
			position -= 2;
			return 2;
		}

		varInt |= (0x80 << 8);
		varInt |= (value << 16);

		value >>>= 7;

		if (value == 0) {
			writeLittleEndianInt(varInt);
			position -= 1;
			return 3;
		}

		varInt |= (0x80 << 16);
		varInt |= (value << 24);

		value >>>= 7;

		if (value == 0) {
			writeLittleEndianInt(varInt);
			position -= 0;
			return 4;
		}

		varInt |= (0x80 << 24);
		long varLong = varInt | (((long)value) << 32);

		value >>>= 7;

		if (value == 0) {
			writeLittleEndianLong(varLong);
			position -= 3;
			return 5;
		}

		varLong |= (0x80 << 32);
		varLong = varInt | (((long)value) << 40);

		value >>>= 7;

		if (value == 0) {
			writeLittleEndianLong(varLong);
			position -= 2;
			return 6;
		}

		varLong |= (0x80 << 40);
		varLong = varInt | (((long)value) << 48);

		value >>>= 7;

		if (value == 0) {
			writeLittleEndianLong(varLong);
			position -= 1;
			return 7;
		}

		varLong |= (0x80 << 48);
		varLong = varInt | (((long)value) << 56);

		value >>>= 7;

		if (value == 0) {
			writeLittleEndianLong(varLong);
// position -= 1;
			return 8;
		}

		varLong |= (0x80 << 56);
		writeLittleEndianLong(varLong);
		write((byte)(value >>> 7));
		return 9;
	}