Use dynamic PBE iteration count.

Fixes #184
Fixes #247