Code cleanup and fix graph visiting
Fixed tests, and fixed graph navigation for visitors