The smart grid which stores position and type of module in the cell helps a lot but cannot handle all moment of movement.
Modules store their position in the grid after stopping movement.
But this behavior made some bugs - when two modules near each other moves fast and grid do not distinguish them by position or unable to check them in the frame - they move and stack in one cell.
I think about semaphores in each cell in the column as in OpenTTD - yellow warning - in next cell module moves, red - in next cell module stops, green - no module in next cell.
Wonder how it implemented in treasures of Montezuma