Tighten up with_extlib logic

- Make sure 'res' is only searched in the local environment