clean-up debug status handling
merge original fork