Improve toString conversion of commands for graph