Avoid race conditions when launching tasks

- Execute tasks in the proper order
- Remove sleep command
Indentation.