Added par['directory'] in case multiple sources that need to be mapped separately are contained in one image.
Tweaked.