RE: the ranks thing, I've always rationalized it as being another holdover from Phase II. I think the concept of Phase II was that Kirk had been an Admiral for a couple years, but his retaking command of the Enterprise was an actual reduction back to Captain (a specially arranged reduction) because he was fed up flying a desk and Admiral Nogura was sympathetic to Kirk's need to be "out there". Kirk being held up as this great hero following the return of the Enterprise from its five year mission was also probably a part of it; if Kirk doesn't want "rank" but rather wants a ship, then public opinion would likely sway towards giving him his damn ship back. So being reduced to Captain makes sense in that context. I can imagine Admiral Nogura sighing, raising his hands in the air, and saying "Okay Kirk, if you want her back badly enough..... you'll have to be demoted of course....."
Decker on the other hand is harder to rationalize. If he's the captain, then he's a captain. He can be temporarily assigned as first officer, but he'll always have the rank of captain and the sleeve stripes to prove it. But we never actually see Decker with captain's stripes, only commander. So what conclusions can we draw? I think Decker wasn't officially a captain yet. He was involved in Enterprise's refit, and he had basically been tapped to be captain following Kirk's recommendation of him to that role, but the papers hadn't quite gone through yet..... so when Kirk steps in and says, "They gave her back to me Will", Decker just has to accept that his promotion hasn't gone through. It also adds an extra dimension to the conflict between him and Kirk.