Originally believed to be an accident according to Peter Jackson, when Gandalf hits his head on a wooden beam inside Bagend it was not scripted but in fact planned ahead of time by the actor according to a 2004 interview with Sir Ian McKellen. Even still many fans believe it to be completely unintentional.