Made debug printing more robust/dynamic across the board