Moves debug mode logic into helper module.