Fix up scope indexing.
Janky port of mapResources().