// Added lock to class_index generation