Revise debug logging logic

Signed-off-by: Tod Fitch <Tod@FitchDesign.com>
Fix memory leaks

Signed-off-by: Tod Fitch <Tod@FitchDesign.com>