Thanks, 93e945e3237d300e13fa7f16044cdaf8364197bb fixes this properly. I wasn't really satisfied with my solution, either.
I didn't have a good enough understanding of how these path functions interacted, so I don't really have an excuse other than I impulsively submitted the first idea that seemed plausible to me.