Updated index rebuild to take into consideration the schema as well.