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

Use `closure_count` instead of `get_num_closures()`.