In deep space, the two Van Baalen brothers—Gregor and Bram--are aboard their cargo freighter. Tricky, their android, is making repairs, while Gregor and Bram sleep. An incoming salvage message lights up and Bram wakes up to check it out while Gregor continues sleeping. It's nothing but floating garbage and Tricky complains about the boredom. He wonders if Gregor will order them back, but Bram insists that they're equal partners and Gregor isn't in command.
As the TARDIS travels through space, the Doctor wants Clara to talk to the TARDIS and apologize so that they can get along together. He suggests that she pilot it and makes it easy for her by shutting the TARDIS down to basic mode and the TARDIS grinds to a halt, The Van Baalens pick it up on their scanners and Tricky detects a high-intensity magnetic field. Gregor, waking up, engages the magno-grab and brings it aboard.
Clara touches the console and it immediately shuts down. Music plays over the speakers and the Doctor discovers that he can't bring the shields back up. The console explodes and while the Doctor tries to get things under control, a small cylinder rolls into the console room. Clara picks it up and then releases it as it burns her hand, while another blast shakes the TARDIS.
The Van Baalens and Tricky go to the cargo hold and assume that the TARDIS is an escape pod. Bram starts pounding on it with a sledge hammer, and then tries to open it with a laser saw. Nothing happens and Gregor tells him to use a thermo-charge. Tricky objects, saying he can sense that the TARDIS is alive and suffering. He also detects someone lying nearby, ejected from the TARDIS. Gregor, realizing that they could be held accountable, tells Bram and Tricky to claim that they did nothing if anyone asks. The Doctor wakes up, comes over, and introduces himself. He knows that they used a thermo-charge to try and disable the TARDIS, and that it would only work if the shields were down. The Doctor realizes that Clara is still onboard, and Tricky warns him that the TARDIS is leaking fuel. If Clara is still aboard, she's dead, but the Doctor doesn't believe it. He grabs some respirators and tells them that they can open the door for a moment and pull Clara out. Gregor tries to negotiate and the Doctor offers them the TARDIS and everything inside if they help him rescue Clara.
Inside the TARDIS, Clara wakes up as the cloister bell tolls throughout the vessel. She discovers that her hand is burned where she held the thermo-charge and blows on it, and then starts exploring. Clara comes to a door with a red flashing light above it and figures that it's a warning. She opens the door anyway and a fireball roars up the corridor toward her. Running off, Clara closes another door behind her and finds what appear to be scratch marks on the wall.
As Tricky and the Van Baalens prepare to open the TARDIS doors, Bram asks Gregor if it's worth the risk. The younger Gregor tells Bram to do what he's told and leave the thinking to him. Meanwhile, the Doctor wonders why Tricky needs a protective suit and Bram explains that he's covered in flesh, making him just as vulnerable as they are. The Doctor kicks in the door and they enter the console room, and they take in the incredibly large interior while he pulls the poison out of the atmosphere. Once they can breathe without the masks, the Doctor admits that parts of the ship are still filled with poison gas and it will take him hours to find Clara... unless they help. When they say that isn't part of the deal, the Doctor activates the self-destruct and tells them that it will explode in one hour. He puts the TARDIS in lockdown and as they pound on the doors, the Doctor resets the timer to thirty minutes, figuring they'll work better under pressure. When he threatens to go to fifteen minutes, they agree to help.
Clara enters a dungeon chamber filled with books and equipment. A figure moves through the shadows and rears up, and Clara runs back out.
As the Doctor and the three salvagers move through the ship, Bram scans for useful equipment and picks up lots of valuable gear. He suggests that they split up and the Doctor reluctantly agrees, but advises them not to touch anything for fear of upsetting the TARDIS. As the Doctor and Tricky go off, Gregor tells Bram to go to the TARDIS console and strip it.
The figure pursues Clara through the TARDIS corridors and she finally takes refuge in a vast library.
Bram returns to the console room and removes one of the console panels. Voices talk about trans-dimensional engineering, whispering in the darkness.
Gregor continues scanning and the AI tells him that everything he could want is behind the next door. He goes through and finds a manufacturing plant, and the scanner tells him that it will build anything he requires. When he starts cutting, the Doctor and Tricky run in and the Doctor tells Gregor to stop before the TARDIS stops him. He explains that it's the TARDIS architectural reconfiguration system and Gregor picks up one of the circuits. The Doctor repeats his warning but Gregor ignores him and a high-pitched noise fills the air. The door into the chamber disappears and the Doctor warns Gregor that the TARDIS won't relinquish its basic genetic material. Tricky refuses to help, insisting that the TARDIS is alive and suffering. When Gregor prepares to blast open a hole, the door reappears and opens and Gregor walks out, confident he's called the TARDIS' bluff.
Clara finds a book--"The History of the Time Wars"--and starts reading it. She finds a reference to the Doctor's real name. However, as she reads it, she hears someone behind her. Clara hides as the hideously burned creature enters the library and moves through the stacks. She hides behind a shelf containing bottles labeled "History of Gallifrey" and knocks one over, spilling out the contents. The creature runs past her and Clara runs back to the corridor.
The Doctor realizes that the TARDIS is reconfiguring the corridors to keep them from reaching Clara, and tells Gregor that it will only release them if he returns the circuit. Tricky calls Bram and tells him not to touch anything, but he's found an access ladder leading down and ignores the android's warning.
Clara finally locates the console room but discovers that the exterior door has disappeared.
As Bram climbs down, the ladder suddenly burns his hand. He loses his grip and falls down, and the creature lunges at him. As it grabs Bram's throat, his skin burns. Gregor and the others hear Bram's screams and he tells Tricky that it's too late, and they need to focus on the salvage. Tricky disagrees, and the Doctor tells them to stop bickering and focus on the fact that there's something else in the TARDIS with them. He scans and discovers multiple life forms closing in on them. More of the creatures attack them and Gregor runs off. The Doctor and Tricky are forced to run off in a different direction.
Clara tries to leave the console room but discovers that the TARDIS is reconfiguring the corridors to bring her back. She calls out, asking the TARDIS why it's doing it, but gets no answer.
The Doctor and Tricky find themselves back in what appears to be the console room. However, the Doctor realizes that it's an echo and the TARDIS is trying to protect them by replicating the safest room aboard. The Doctor brushes some parts aside and they disappear, reappearing next to Clara in her echo of the console room. He realizes that the TARDIS is flickering the two echoes back and forth at super-infinite speed. Concentrating, they can hear Clara gasping for breath. Meanwhile, Clara tries to leave the console room again and finds one of the creatures waiting for her.
Clara runs for the console, trying to keep it between her and her attacker. Meanwhile, the Doctor tries to pinpoint her position so that he can reach her. Gregor arrives and his scanner reports that Clara is nearby. The Doctor uses his sonic screwdriver, aligns the two echoes, and pulls Clara through just in time. Furious, she demands to know why there are zombie creatures in the TARDIS. Gregor tells the Doctor to stop the self-destruct now that they have Clara, and the Doctor admits that there is no self-destruct. However, as he tries to turn it off, he discovers that the engine really is exploding. The Doctor opens a panel in the wall and explains that they're taking a detour to the centre of the TARDIS.
As they make their way through the corridors, more of the zombies follow them. Clara asks what the Doctor knows about them, but he tells her that there are some things that she doesn't want to know. They run and Clara gets separated from the others. As she looks for them, her hand sizzles and words start to appear in the burn, reversed. Another Clara appears, and another one, and none of them notice each other or the real Clara. Clara finds the Doctor but he doesn't acknowledge her. The real Doctor comes in and tells her not to touch the other Doctor. He explains that there's a time rupture and the TARDIS is leaking the past. One of the zombies advances on them and the Doctor says that they need to run before "she" catches them. Clara wonders what he knows about the zombie but the Doctor tells her not to ask anything else.
The zombie finally chases after a set of past-images of the Doctor and Clara. The Doctor realizes that they're under the fuel cells and a series of poles burst out of the walls. They run and find Gregor and Tricky. A pipe has impaled Tricky to the wall, and he tells Gregor to cut him free, figuring they can replace the parts later. Gregor refuses and the Doctor tells him to tell Tricky the truth. Tricky wonders what he means and the Doctor tells him that he only has two synthetic eyes and a voicebox: otherwise he's human. Gregor says that it was a stupid joke and they just did it to relieve the boredom.
Gregor cuts through the impaling pipe, freeing Tricky, and they go to the power source. The Doctor tells them to wait outside while he goes in. While they wait, Tricky snaps at Gregor, demanding to know who he is. In response, Gregor gives him his Van Baalen Bros. patch and explains that Tricky is his kid brother. Tricky lost his memory, his sight, and his voicebox during an explosion. Before that, their father had made Tricky the captain because he was always the smart one. Furious that Gregor made him think he was an android so he could become captain, Tricky lunges at Gregor. The Doctor comes out and separates them, and points out that Gregor couldn't cut him up because he still has some decency. He tells Gregor not to forget what happened and then takes them into the power room. The Doctor explains that the TARDIS power source is the Eye of Harmony, an exploding star becoming a black hole.
They continue to the next room only to find one of the time zombies waiting for them. They retreat only to find more time zombies back the way they came. Clara demands to know what they are and why the Doctor is keeping secrets. He insists that secrets keep them safe, but Clara points out that none of them are safe. Meanwhile, Gregor scans the zombies and the Doctor, realizing what he's doing, tells him to turn it off. Before the Doctor can stop him, the scanner announces that the zombie has Clara's DNA. The Doctor explains that the future is also leaking and Clara dies again.
Clara wonders what he means about dying "again," but the Doctor gets an idea and says if they can interrupt the timeline then nothing they've seen has happened. He remembers seeing two of the zombies merged together and pulls Gregor and Tricky part to prevent what he saw from happening in the future. One of the zombies breaks in and grabs Gregor's backpack with the circuit. They tell him to let it go and he finally does, and Tricky knocks the zombie into the power core. The two linked zombies charge in and after a moment's hesitation, Tricky attacks them and knock them off the railing into the core. They fall but grab him, and he dangles over the edge. Refusing to abandon his brother despite the Doctor's warning, Gregor pulls tricky up... and the energy from the power core causes the two of them to merge together and burn. The recreated twin-zombies charge at the Doctor and Clara, who run out and slam the door behind them.
The Doctor leads Clara to the engine room but a vast chasm blocks their way. He admits that he doesn't have a plan and that they're as good as dead, so he asks Clara for the truth. The Doctors asks who she really is and says that he keeps running into her and she keeps dying. Clara insists that she has no idea what he's talking about and almost falls into the chasm as she backs away in fear. The Doctor pulls her back and realizes that she's telling the truth. He hugs her and then realizes that the chasm isn't really there. The TARDIS is trying to scare them away and all they need to do is jump. He asks Clara to trust him and she does, and they jump into the abyss together.
The duo finds themselves in a white void filled with floating engine fragments. The Doctor realizes that the engine has already exploded after they crashed into the salvage ship. The TARDIS contained the explosion temporarily, but there's no way the Doctor can save them. He doesn't know what to do, and Clara takes his hand. The Doctor sees the branded writing on her hand, gets an idea, and scans for the leaking moment of time when they crashed. They enter the echo of the console room at that moment where there is a time rift in the wall. The Doctor realizes that the thermo-charge Clara picked up earlier came through the rift because he threw it through in their present. As he goes to the rift, the Doctor that Clara will forget everything that she's learned. She says that she doesn't want to forget and that she saw his name in the library. The Doctor silences her before she can say it and says that she'll forget that as well, and that it's better that way. He then braces himself and reaches into the rift...
The TARDIS console explodes and the future Doctor steps through the rift and calls to his present self, saying he's from the future. He tosses in the thermo-charge before dissolving in the time stream, and Clara picks it up. It burns her hand and she drops it, and the Doctor manages to catch it. He sees the message that his future self has etched on his side, the message that was on Clara's hand: "Big friendly button." The Doctor pushes the button on the grenade...
The Van Baalens detect the TARDIS floating in space but loses it after a second when it disappears. When Bram tells Tricky the robot to get him some food, Gregor tells him to stop. When Bram wonders why, Gregor says that maybe he has a tiny spot of human decency.
The TARDIS continues on its way, the collision with the salvage ship never occurring. The Doctor asks Clara if she feels safe and she assures him that he does. He rambles on about having her think of a number and insists that he needs to know that she's not afraid. Clara says that anything could happen... and that's what she's counting on