Refactored and fixed bugs with path saving during rebuild.