moar code rewrite

fully working, and visualizations.js is short and sweet