Fix "provides" crashes and incorrect lookups