People tend to give Whedon credit for plotting out and setting up every twist years in advance, but if BUFFY was like other TV shows, lots of stuff, even major plot-twists and arcs, were probably thought up in the writer's room the week before the episode aired.