Improve debug and log with cmd string storage and toString.