A council has been fined £300,000 after admitting a health and safety failing following the death of a 15-year-old boy who was hit by a school minibus.
Ashley Talbot died in December 2014 following the incident in the grounds of Maesteg Comprehensive School.
The teacher who drove the minibus was not prosecuted but the Health and Safety Executive brought a case against Bridgend borough council.
Cardiff Crown Court was told Ashley's death could have been prevented.
Changes have been made since the incident to improve children's safety, and the council has apologised to Ashley's family.
The court heard how the council failed to address "hazardous" issues with bus parking provision.
Concerns over drop-off points, walkways and road parking had been raised during construction in 2008, but the council was told by its health and safety officer it was "highly likely no changes would be made" at that stage.
Suggestions to improve safety were made in 2011 but no agreement was made, which prosecutor Simon Morgan described as a "clear misunderstanding" and a "complete failure in health and safety communication which resulted in a missed opportunity".
Judge Eleri Rees described the incident as a "tragic event which shocked all present" and as "devastating for the family".
She added: "The fact the death could have been avoided had the correct safety measures been put in place makes it even more painful", and said concerns "fell on deaf ears".
She said it was "unfortunate that insufficient attention was given to safety when planning the design of the school".
Mr Morgan said pupils would walk between parked vehicles into the road to get to their bus.
School staff and bus drivers told the court there had been a number of "near misses" before Ashley's death - including three weeks beforehand when a boy walked out between parked buses and a minibus had to "brake hard".
A bus driver described the situation at the end of the school day as a "free for all".
Mr Morgan said Ashley's death could have been prevented had "reasonably practicable changes been made", adding "hundreds of pupils were put at risk".
In February 2017, an inquest jury concluded Ashley's death was an accident.
Since the incident, changes have been implemented including a lock-down at the end of the school day to allow children to get on the buses safely and better supervision.
Paying tribute shortly after his death, Ashley's family said: "He would brighten the darkest of rooms with his smile and sense of humour.
"Our son was our life and he was loved as a brother and we wouldn't change him for the world.
"He was a typical teenager, a practical joker with a wicked infectious laugh.
"Ashley will be missed so much by everyone, but will be with us forever in our memories."