Reorganize visualization code a bit