Allow profiler max depth to be configurable.

This will close #515.