public String readVarIntString(DataInputStream stream, int maxLength) throws Exception {
		int length = Varint.readVarInt(stream);
		if (length > maxLength * 4)
			throw new Exception("The received encoded string buffer length is longer than maximum allowed (" + length + " > " + maxLength * 4 + ")");
		if (length < 0)
			throw new Exception("The received encoded string buffer length is less than zero! Weird string!");
		byte[] in = new byte[length];
		stream.readFully(in);
		String s = new String(in, Charset.forName("UTF-8"));
		if (s.length() > maxLength)
			throw new Exception("The received string length is longer than maximum allowed (" + length + " > " + maxLength + ")");
		return s;
	}