When designing cyber-physical systems, especially in industrial automation, model-driven engineering plays an essential role in ensuring software maintainability and supporting evolution. Whereas textual programming environments provide mature tool support for refactoring and maintenance, equivalent capabilities in visual languages remain underdeveloped. This research addresses the challenges of maintaining and refactoring models in typed block-based modeling languages, such as IEC 61499 and Simulink, which are frequently used in industry. We propose a methodology that embeds repair mechanisms directly into refactoring processes, ensuring model consistency and minimizing manual intervention. By introducing a meta-model-based approach, we identify common maintenance operations and systematically define transformations that preserve the execution semantics while improving maintainability. Our approach is evaluated through a cross-language implementation, demonstrating its applicability across different modeling tools and industrial settings. We developed the concepts and assistance tools in close collaboration with our industry partner to enable software maintenance of large-scale automation software. The lessons learned are generalizable for various tool developers and contribute to error-resilient model evolution in visual modeling environments.