Fixed some typing problems
Added running till no task
Every iteration waits for an event to happen before it updates