Path-related bugfix for broken prior images.

Hopefully these changes will insulate the code against path changes in the future. I'm unfortunately still not certain what broke this in the first place, the older version still works perfectly on my own machine.