Further refactoring of brush script code