Make thread_count parameter safer to use