diff --git a/flash2d/src/options-sphere/IO_vtu_stacked.F90 b/flash2d/src/options-sphere/IO_vtu_stacked.F90
index 7fdcb7e5f912648b063d88466b52f888327e6be9..2b2493e4d0121b787aaf70278e9aad26804dce68 100644
--- a/flash2d/src/options-sphere/IO_vtu_stacked.F90
+++ b/flash2d/src/options-sphere/IO_vtu_stacked.F90
@@ -186,7 +186,7 @@ SUBROUTINE plot_vtu(p_mesh, c_filename, &
 
 #if defined VTU_OUTPUTSTC
   i_numberofvtucells = p_mesh%i_enumfine* (i_lay-1)
-  i_numberoffvtuaces = p_mesh%i_gnumfine* i_lay + p_mesh%i_nnumber* (i_lay-1)
+  i_numberofvtufaces = p_mesh%i_gnumfine* i_lay + p_mesh%i_nnumber* (i_lay-1)
 #endif
 
   IF(l_continuous_data) THEN
@@ -394,7 +394,7 @@ SUBROUTINE plot_vtu(p_mesh, c_filename, &
 	END IF
     DO i_cnt = 1, i_nodedata
       IF (p_nodedata(i_cnt)%c_name(1:5) == 'layer') THEN
-        READ(i_hcnt,'I8') p_nodedata(i_cnt)%c_name(6:32)
+        READ(i_hcnt,('I8')) p_nodedata(i_cnt)%c_name(6:32)
         i_stcbeg = p_mesh%i_nnumber*(i_hcnt-1)+1
         i_stcend = p_mesh%i_nnumber*i_hcnt
         r_stcval(1:1,i_stcbeg:i_stcend) = p_nodedata(i_cnt)%p_vdata(1:1,:)
@@ -404,6 +404,7 @@ SUBROUTINE plot_vtu(p_mesh, c_filename, &
     p_stcnodedata(1)%i_size = 1
     p_stcnodedata(1)%p_vdata=>r_stcval
     CALL write_vtu_data(i_fhandle, p_stcnodedata(1))
+    DEALLOCATE(r_stcval)
 #endif
   END IF
 
@@ -434,7 +435,6 @@ SUBROUTINE plot_vtu(p_mesh, c_filename, &
   END IF
 #elif defined VTU_OUTPUTSTC
   ! at this time we assign the same cell values to the whole column of stacked cells
-  IF(ALLOCATED(r_stcval)) DEALLOCATE(r_stcval)
   ALLOCATE(r_stcval(1,i_numberofvtucells), stat=i_alct)
   IF(i_alct /= 0) THEN
 	CALL grid_error(c_error='[plot_vtu]: could not allocate aux. stc values arrays')
@@ -443,13 +443,14 @@ SUBROUTINE plot_vtu(p_mesh, c_filename, &
       DO i_hcnt=1,i_numberofcells
         i_stcbeg = (i_hcnt-1)*(i_lay-1)+1
         i_stcend = i_hcnt*(i_lay-1)
-        r_stcval(i_stcbeg:i_stcend) = p_celldata(i_cnt)%p_vdata(i_hct)
+        r_stcval(i_stcbeg:i_stcend) = p_celldata(i_cnt)%p_vdata(i_hcnt)
       END DO
       p_stcnodedata(1)%c_name = p_celldata(i_cnt)%c_name
       p_stcnodedata(1)%i_size = p_celldata(i_cnt)%i_size
       p_stcnodedata(1)%p_vdata=>r_stcval
       CALL write_vtu_data(i_fhandle, p_celldata(i_cnt))
     END DO
+    DEALLOCATE(r_stcval)
 #endif
 
   ! write the end of cell data and the footer.
@@ -461,9 +462,6 @@ SUBROUTINE plot_vtu(p_mesh, c_filename, &
   ! tidy up
   CLOSE(i_fhandle)
   DEALLOCATE(r_nodecoor, i_cellnodes)
-#if defined VTU_OUTPUTSTC
-  IF(ALLOCATED(r_stcval)) DEALLOCATE(r_stcval)
-#endif
 END SUBROUTINE plot_vtu