Refactor task dispatching to dispatch only one at a time