Updated replace segue to use a much better system for determining the number of view controllers to replace.