Fix bug in add_rebuild