Refactored stack debug functions, hiding implementation details now.