Small fixes to debug printing, esp escaping % signs for printf.