Clean up main; move viz stuff into separate function