Rewritten mpdm_join_s() to only have one exit point.