I would go with the nexus 5 because of the low price and you get a whole lot for that. The S4 has a couple more features one being the IR blaster which I like, but pricey.
I see it this way n5 has best quad core, 2gb ram, HD 1080p 445ppi display, and KK4.4. Either phone you choose will still be relevant 3-5 years down the line receiving the latest android version at that time. Look at the galaxy nexus, nearly 3 years old and already got KK4.4 thanks to PG. More than what can be said for some phones that came out this year and will never get KK4.4 lol.
The Mega is a nice phone, but aside from the big screen it's just an over priced mid range dual core phone with an older version of JB and no planned update. Aside from big screen and couple features, not much of an upgrade from the Spirit.