Fix: reorder things so that the log reads in the right order
Fix: terminate the $log