Iteration branch pull request for review.

Use conditional compilation to only do this in debug mode.