Optimize mesh generation