Fixed a bug in pdf weights for OSL closures. Improved code.

I suggest getting rid of `ie`, it makes things very confusing. Just use `closure_count - 1`.