Fix defects that resulted in the order of items in the processing pipeli...

...ne to be changed.

The sort method for updating the processing middleware pipeline was occasionally rearranging the items (weren't getting assigned a middlewarePriority).  I've simplified the method by simply appending the new middleware to the end of the pipeline and then moving it to the appropriate place in the pipeline.

Limited manual testing was done.  Hopefully we can get the unit tests working soon.