I think the large number of people voted for the freebies and the Dems were able to build false votes where they needed them.
I believe that was a big part of it.
I think the Dems calculated where they could stuff enough ballot boxes to carry the POTUS election, and then did so. (Philly, Ohio, for instance).
I also think they may have done the same thing to keep control of the Senate, because without that, DUH-1 would be vulnerable to getting impeached over Benghazi, or fast and furious, among other things.