Refactoring and visualization scripts