Sliver of Sight
Intruders were a common and annoying issue back in the day, so one way to handle them was entrapment within the courtyards. Once they realized their plan had no escape route, the invaders would be shot at with a bow and arrow through a thin sliver of the castle walls. Inhabitants would fire away!
Breaking Barriers
Two barriers typically created the main gate for one very clever reason. Should invaders have made it past the first entrance, there was always a chance that they could get caught between the first and the second barrier. Once there, the siege they had planned would be entirely debunked.