Potential fix to 1700.
Make profiling code a bit less fragile.

This assert was technically correct right now. But it's easy to get
wrong if you have exceptions being thrown.
Doctored NOTES

Review 1052 by @mglukhovsky
Merge branch 'next' into sam_97_alt