Cap on exceptions

Fixes #307