Fix bugs w/hashes and queries when compacting to relative IRIs.