Fix thread ordering