some optimizations to reduce the number of meshes