Added events and tasks handling for window