Improving mesh management code