Diluted Wine Puzzle

This was a rather intricate puzzle from Presh Talwalkar. I found his solution a bit hard to follow, so I tried for a clearer presentation.

“A servant has a method to steal wine. He removes 3 cups from a barrel of wine and replaces it with 3 cups of water. The next day he wants more wine, so he does the same thing: he removes 3 cups from the same barrel (now with diluted wine) and replaces it with 3 cups of water. The following day he repeats this one more time, so he has drawn 3 times from the same barrel and has poured back 9 cups of water. At this point the barrel is 50% wine and 50% water. How many cups of wine were originally in the barrel? ”

See the Diluted Wine Puzzle.