diff --git a/Runtime/Lidar/LAZLoader.cs b/Runtime/Lidar/LAZLoader.cs
index d2d9150a695f1cbbca75cbde681f74a732e47128..c8171d8a6aff1d49b7b91daeeccf4ec20715780f 100644
--- a/Runtime/Lidar/LAZLoader.cs
+++ b/Runtime/Lidar/LAZLoader.cs
@@ -674,7 +674,7 @@ namespace LAZNamespace
         #endregion
 
         #region Generic Tasks
-        public GenericTask StartGenericTask( Action callback, Action onDone=null )
+        public GenericTask StartGenericTask( Action callback, Action onDone=null, bool executeOnMain=false )
         {
             // Lazy initialize, if not already on main thread.
             if (genericTasks == null)
@@ -690,6 +690,8 @@ namespace LAZNamespace
             gt.done = false;
             uint taskIdx = (uint) genericTaskIterator++;
             taskIdx %= (uint)numGenericTasks;
+            if (executeOnMain)
+                taskIdx = 0; // This allows ordered execution of tasks.
             lock (genericTasks[taskIdx])
             {
                 genericTasks[taskIdx].Add( gt );
diff --git a/Runtime/Lidar/LAZOctreeCell.cs b/Runtime/Lidar/LAZOctreeCell.cs
index 50377cd5f23ecb84e9e21254ff534165790b96ac..7c2b6c4ece332b8f1cfb963a7cb80c8d5b4bdc52 100644
--- a/Runtime/Lidar/LAZOctreeCell.cs
+++ b/Runtime/Lidar/LAZOctreeCell.cs
@@ -495,7 +495,7 @@ namespace LAZNamespace
                 var verticesSliced = vertices;
                 if (verticesSliced== null) // Might be unloading the data.
                     return;
-                System.Diagnostics.Debug.Assert( Directory.Exists( tree.PathToCacheFolder ) );
+                Debug.Assert( Directory.Exists( tree.PathToCacheFolder ) );
                 var filePath = GetPathOnDisk().NormalizePath();
                 Monitor.Enter( this );
                 try
@@ -510,6 +510,7 @@ namespace LAZNamespace
                         {
                             verticesSliced[i].Write( br );
                         }
+                        br.Flush();
                     }
                 }
                 finally
@@ -556,7 +557,7 @@ namespace LAZNamespace
                             verticesNew.Add( ver );
                         }
                         numPoints = verticesNew.Count;
-                        System.Diagnostics.Debug.Assert( verticesNew.Count==vertCount, "Cache invalid. Clear cache and Reload files." );
+                        Debug.Assert( verticesNew.Count==vertCount, "Cache invalid. Clear cache and Reload files." );
                         vertices = verticesNew;
                     }
                 }
diff --git a/Runtime/Lidar/LAZOctreeCellData/LAZOctreeCellMesh.cs b/Runtime/Lidar/LAZOctreeCellData/LAZOctreeCellMesh.cs
index 6bf239eafa7e7ffb175d0ceb1ea0223ea198264b..e76df1a52aeb78f7b143a4f7bd91fa349e157768 100644
--- a/Runtime/Lidar/LAZOctreeCellData/LAZOctreeCellMesh.cs
+++ b/Runtime/Lidar/LAZOctreeCellData/LAZOctreeCellMesh.cs
@@ -59,13 +59,13 @@ namespace LAZNamespace
                             } );
                         }
                     }
-                    // Regardless of visible, we must finish the task, otherewise it will only due when visible, but task was already started.
-                    if (loadVoxelTask != null && loadVoxelTask.done)
-                    {
-                        loadVoxelTask = null;
-                        FinalizeMeshData();
-                        UnityEngine.Debug.Log( "done updating mesh" );
-                    }
+                }
+                // Regardless of visible, we must finish the task, otherewise it will only due when visible, but task was already started.
+                if (loadVoxelTask != null && loadVoxelTask.done)
+                {
+                    loadVoxelTask = null;
+                    FinalizeMeshData();
+                    UnityEngine.Debug.Log( "done updating mesh" );
                 }
                 return mesh;
             }