Honestly, like everyone has said before, four is extremely old for a Betta.
It almost sounds like dropsy, but in that case, there isn't a whole lot you can do. Not many of us look at the insides of the fish after they've died, so we don't really know if dropsy does have yellow clear fluid Seriously, though. Four years is GOOD. Do NOT change anything. You've done well by your fish, and you can't expect him to live to be the ripe old age of 20.
Mos people only have their little finned friends for 2 years before they day. You've done an excellent job with him. ESPECIALLY since you got him at walmart.
Your worst mistake would be to change anything, because you have managed to have him for so long. Just get another Betta, probably another color, and do it again. Give your little friend a nice little burial, and keep on chugging.
Bye bye little betta!
And really, you did an excellent job. You should be proud of yourself that you gave him such a long, happy life.