@SuppressWarnings("unchecked")
	public void decodeMetadata(InputStream is) {
		try {
			// DECODING
			Bencode bencode = new Bencode(is);
			TreeMap<ByteBuffer, Object> map = (TreeMap<ByteBuffer, Object>) bencode.getRootElement();
			is.close();

			// ASSIGNING VARIABLES FROM METADATA
			announce = new String(((ByteBuffer) getEntry(map, "announce")).array());
			info = (TreeMap<ByteBuffer, Object>) getEntry(map, "info");
			info_hash = computeHash(info);
			info_hashEncoded = computeHashEncoded(info);

			// ASSIGNING VARIABLES FROM INFO
			piecesLength = (Long) getEntry(info, "piece length");
			piecesString = new String(((ByteBuffer) getEntry(info, "pieces")).array());

			if (getEntry(info, "files") != null) {
				// multi-file TODO AT SOME POINT
				numFiles = TorrentType.MULTIFILE;
				fileFolder = new String(((ByteBuffer) getEntry(info, "name")).array());
			} else {
				// single file
				numFiles = TorrentType.SINGLEFILE;
				fileName = new String(((ByteBuffer) getEntry(info, "name")).array());
				fileLength = (Long) getEntry(info, "length");
			}

			int numPieces = getPiecesString().length() / 20;
			for (int i = 0; i < numPieces; i++) {
				pieces.add(i);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}