When the Simpsons go to visit Ned at the Mental Hospital they pass three rooms. One has Mrs. Botz, the deranged babysitter from Season 1, one has Simpsons writer John Swartzwelder, and the third one has Jay Sherman.
A caricature of writer John Swartzwelder can be seen shutting the door of a room in Calmwood Mental Hospital. Later in the episode, during the scene where the townsfolk are welcoming Ned back, someone can be seen holding a sign that says "Free John Swartzwelder".
The original idea came from George Meyer, who had also wanted an episode about Flanders' faith being tested. One of the key story points came from his friend Jack Handey, a writer for Saturday Night Live (1975), who wanted to do a sketch about a down-on-his-luck shoemaker who is visited by elves who help him, but make very bad shoes. Likewise, it inspired the idea that the neighbors would rebuild Flanders' house, but do a bad job and provoke an outburst.
The writers wanted to explore what made Flanders tick and examine what made him act the way he does.