Use size_t consistently across thread code