Make debug mode a parameter, not a setting

This is my version of #357