Fixed bugs in the visualizer