Fix duplication when rebuilding