#17187 - tidy up use of dbg and set var if not set