Refactored some brush script code