Mr. Smithers enters a storage cupboard in the power plant and accidentally leaves the door open. Homer, seeing this as an opportunity to steal supplies, tells everyone to come and help themselves and every employee steals something. However, Homer then sees Mr. Burns approaching and hurries away from the plant, leaving his fellow employees to get all of the blame. Homer is thought to be the only one who did not steal anything and gets a day off, which he spends going fishing with Bart. The next night, Homer wets the bed while asleep. When he wets the bed again the following night, he thinks that karma may be the reason, so he apologizes to all of his fellow employees with a free barbecue for everyone. That night, Homer wets the bed again and gets angry over a wasted act of kindness. He buys a bedwetting alarm that will warn him when he is about to urinate in his sleep. This machine, however, wakes up the entire family and he must explain his predicament to them. Homer then starts wearing Confidence Man Adult Diapers which are a turn-off to Marge, and she goes for a walk. She bumps into Professor Frink, who reveals that he has invented a machine that can be used to enter other people's dreams. They plug in Homer while he is asleep and the family enters his dream in which he is skiing down a snowy mountain. There, they meet Death who is dragging a coffin that reads "Marriage". After falling off a cliff while pursuing Death, they use the dream machine to enter Bart's dream. In this dream, the family is drawn in their original style from The Tracey Ullman Show (which ironically, aired on Fox's television stations in 1987, after News Corporation's acquisition of the Metromedia stations in 1986), with Homer using his original Walter Matthau-style voice. Family therapist B.F. Sherwood tells them to open the coffin. When it is opened, the room starts to fill with fish, so the family use the machine to go to the next dream, which is Lisa's, but when they find that they are on an Elizabethan stage show, they immediately change dreams again, going back into Homer's.
Homer's newest dream depicts a city made of his greatest desires. After exploring the dream, Homer decides he wants to stay in it forever. At this point, Chief Wiggum, Eddie and Lou have entered the Simpsons' home to try to get the dream machine from Professor Frink. In the resulting fight, the dream machine falls to the floor, which causes a disturbance in the dream, in which a large bottle of Duff Beer falls over and floods the city. The Simpsons are nearly crushed by two large gears, but they are rescued by Death, who is revealed to be Mona Simpson, Homer's late mother. Mona then takes the family to a movie theater where they view a childhood memory of Homer's. He and Grampa went on a fishing trip and the boat capsized. They then returned to their holiday home several hours late and without any fish. A couple of weeks following the incident, Mona left Grampa and Homer. This left Homer guilty as he thought that the failed fishing trip caused his mother to leave. However, Mona reassures him that it was not because of this and shows another memory of her being relieved that Homer, her greatest treasure, was safe because of Grampa, and Homer finally feels comfort. Now knowing the reason behind Homer's bed-wetting, the family leaves the dream before it collapses on itself. Back at the Simpson home, Chief Wiggum finally manages to get the device from Frink and detaches it just as everyone wakes up. Homer is relieved to find he has not wet himself. That night, Homer spins a top, with Marge telling him that if it keeps spinning, they are still in a dream. It does so they decide to strip naked and go for a bike ride. However, as soon as they leave, the top falls on its side and it starts to hail. A truck then hits Homer. Behind the end credits, David Byrne and Glenn Close sing a version of "Dream Operator" from the David Byrne movie "True Stories".