Removed some duplicate code in the visualizer.