Add ReplaceSeries and refactor the CreateSeries function into smaller steps

Might be a good time to fix this part. We should be making a copy of the rawPubKeys here and sorting the copy instead of manipulating the input.