Altered main loop structure to utilise a separate timestamp for each zdir.
This prevents some problems when loop iteration times exceed the time between updates.