Changed object_index to virtual and added constructor