bug fix, and debug code for tracing train rout