Fixing a segmentation fault on the spinOnce function.