Replaced raw use of Thread with spawn