Optimizations for mesh cleanup