Little refactor of visualization code