made visualizer into a class and improved performance and some tweaks