Make TaskManager safe for concurrent access