added debug mode stack printing