Fix URI matching and generation.