@SuppressWarnings("unchecked")
	private static final Object[] decodeDictionary(byte[] bencoded_bytes, int offset) throws BencodingException
    {
        HashMap map = new HashMap();
        ++offset;
        ByteBuffer info_hash_bytes = null;
        while(bencoded_bytes[offset] != (byte)'e')
        {

            // Decode the key, which must be a byte string
            Object[] vals = decodeString(bencoded_bytes, offset);
            ByteBuffer key = (ByteBuffer)vals[1];
            offset = ((Integer)vals[0]).intValue();
            boolean match = true;
            for(int i = 0; i < key.array().length && i < 4; i++)
            {
                if(!key.equals(ByteBuffer.wrap(new byte[]{'i', 'n','f','o'})))
                {
                    match = false;
                    break;
                }
            }
            int info_offset = -1;
            if(match)
                info_offset = offset;
            vals = decode(bencoded_bytes, offset);
            offset = ((Integer)vals[0]).intValue();
            if(match)
            {
                info_hash_bytes = ByteBuffer.wrap(new byte[offset - info_offset]);
                info_hash_bytes.put(bencoded_bytes,info_offset, info_hash_bytes.array().length);
            }
            else if(vals[1] instanceof HashMap)
            {
                info_hash_bytes = (ByteBuffer)vals[2];
            }
            if(vals[1] != null)
                map.put(key,vals[1]);
        }

        return new Object[] {new Integer(++offset), map, info_hash_bytes};
    }