Added better checking for debug settings, plus default values.