Changes as requested by @cpeterso.

Moved the code to a separate private method, controllable during execution by the relevant piece of code, depending on context.