Add code to handle chain builds with sets better.
When doing chain builds, the last package can be treated one of two
ways.
1) It can be added to the end of the list to be built serially, it would
be the last build.
2) It can be added to the last set in the chain to be built in parallel
with the last set.
Which way depends on if sets are used or not. This code should handle
both correctly.