Few schools can be in more tranquil settings. Merrick is little more than 10 miles from the M74, connecting Glasgow and the English border, but it feels a world away.
A quiet road from the motorway twists through green slopes, leading to a bumpy approach track and sheep that are utterly bemused to see a car. On one side of the school is a cloud-scraping hill, on the other a picturebook glen. In other circumstances, this spot would be thronged with cooing tourists.
For now, the school's three pupils, all boys, need a place like this. Each has endured setbacks, if not trauma, whose effects have rippled out to all parts of their lives, not least school.
The boys have struggled badly in mainstream education, their frustration and isolation at times boiling to violent rages. Put so much as a book in front of one in particular, and he will hurl it against a wall.
Common Thread, the not-for-profit body that runs Merrick School from a converted farmhouse, for a maximum of four pupils, wants each boy to return to mainstream education. But for now they are insulated from the outside world, in a place designed to resemble a loving home as much as a school. Educational, yes; institutional, absolutely not.
Through an old country kitchen, where bowls of soup have been set on a table, the boys wander freely and chat with staff about whatever comes to mind. The staff keep an eye on them, but on the surface at least, it is with the half-distracted air of a dad flicking through the Sunday papers, not the beady surveillance of a disciplinarian teacher.
James, 14, made the soup. Gordon Ramsay is his hero and he wants to run his own restaurant, thinking he could make a lot of money. But he will not rake in all the profits for himself; he wants to "give help to those in need", specifically the homeless and children in Africa.
James, who has Asperger's syndrome and ADHD (attention deficit hyperactivity disorder), grew up in an environment where failure was not an option. When I ask him if he will go to college to study hospitality, he corrects me: he will go to university, not college. He is adamant that he will soon be doing eight subjects to exam level; later, staff tell me James is not yet ready for such demands. Sensitively, they will need to recalibrate his ambitions.
James talks to me while headteacher Martin Halstvedt waits outside. James "loves" Merrick, where he has been for about three months, and says the quiet atmosphere and one-to-one tuition help him learn. There are "not so many people trying to dispute what you're trying to say - you get to speak your mind". It is not hard to imagine James, who speaks softly and makes fleeting eye contact, being drowned out in a boisterous classroom.
Common Thread has 11 young people, including the three Merrick pupils, in seven homes. They are working through deep-seated issues that go far beyond gaps in their education, and which make days highly unpredictable.
One girl had an extreme reaction because a staff member wore the same aftershave as an abuser. Martin, who like all staff is known to pupils by first name, is conscious that his 6ft-plus frame can make him resemble the tall men often responsible for inflicting pain in children's lives. Even a browse through Google Earth is risky if a child sees a street linked with a painful memory.
Merrick School is in a building that also serves as the Common Thread home of three other young people (these boys stay elsewhere). One 13-year-old girl set a record for smashed windows: 45. She arrived, staff say, in "total turmoil", but has settled well after a month. She has been in care since the age of two, and has already been through 15 placements. Soon the local authority will move her on again.
Common Thread was founded in 2004 and Merrick School opened late in 2008. The school was a way of helping children who had become snarled in local government bureaucracy. "There was this gap in terms of education," says Julie Joseph, managing director of Common Thread. "Either children were stuck for months while forward-planning happened and there was no educational input, or the education on offer didn't meet their needs."
What marks out Merrick School and Common Thread, which calls on 60 staff, is a philosophy that seeks to remove divides between care and education. "Teachers speak a very different language from care. Could we create a common language?" asks Julie.
Martin, a former principal guidance teacher, sees "phenomenal work" in education and social work, but believes they do not integrate well. He bemoans poor record-sharing, incompatible data systems, and children who have "disappeared from education" or had the "demoralising" experience of being made to repeat work.
The gap between education and care is conceptual as much as logistical, he believes: "I would argue that teachers are frontline social workers. I said that in a room of teachers once. The whole place went quiet." But Martin is adamant: "This is not a job - you're a corporate parent first."
Common Thread business development manager Derek Bannon is a convert to the cause from the other side, as a former local authority social work manager. "If you're a teacher, you're a person," he says. "You need to trust the relationship before you can start the education."
Merrick uses care workers as classroom assistants. "They have such depth of knowledge and interest in their young people that it would be a waste if we were not to involve them in the young people's education," says school founder Amy Young, a former learning support teacher and Julie's mother.
Carers' time in the classroom, she explains, can help them spot opportunities for learning elsewhere, such as games of I Spy with phonic rules on long car journeys. Children at Common Thread also like to know who will be around them each day - the same staff who put them to bed are there when they wake in the morning - and carers can spot signs of rising tension in the classroom.
"We have to hide education and make the pupils think it's not education," says Martin, who likens their reintegration into mainstream schooling to the preparation of the trapped Chilean miners for the outside world.
Steven, at eight, is unusually young to be in care. He has not had a mother in his life since infancy. He has problems making attachments with adults and is not good at spotting dangerous situations.
He had a deep aversion to writing, but signs of progress are on the wall: "Dracenstein Werewolf", a piece of writing that wittily fuses tales of iconic monsters, is proudly printed in red Gothic type.
He is proud, too, of his turquoise T-shirt, part of the school uniform he helped design. For pupils who have learnt to resent school, having a say in how school looks is considered crucial. So pupils did the tiling in their art room. "It's not the tidiest job, but if you get a professional in, where's the ownership?" asks Martin.
Downstairs, 14-year-old Gordon smiles, throws an arm around Julie and says, "I've got the boss". He grew up in an environment where education was not valued and criminal behaviour was common. Insecure about his own abilities, he would refuse to go to school. He can phone family members in a good mood, only to put the receiver down in a rage and refuse to do any work. Just the mention of "school" has triggered furious outbursts.
Gordon has found that school can be enjoyed. He understands Merrick's approach to bad behaviour. "There are consequences, but they need to be related to the event," says Martin. If you tip over a tin of paint, you tidy it up - you do not receive arbitrary lines or detention.
Gordon may not like books, but he enjoys reading manuals in the workshop which he created himself from a store room. He has been building a go-kart and has put up a coop for several chickens he rescued from a battery farm, whose eggs he sells to staff.
Martin gets frustrated that many mainstream teachers simply dismiss boys like Gordon as inherently, unchangeably bad. He believes that if better information about such pupils' backgrounds were shared, attitudes would change.
Merrick received its first HMIE report in August this year, a generally positive assessment. Common Thread has been delighted with the support from inspectors, as well as the Scottish Qualifications Authority and the Scottish Government, but Julie says the inspectorate's expectations do not always square with life at Merrick.
There were reservations about the absence of separate toilets for adults and children, for example, but that was a deliberate policy to mimic the feel of a family home. The school does not provide a broad enough curriculum, according to HMIE. Merrick, however, has to concentrate on what its local authority clients deem important, and one authority caused frustration by stipulating only literacy and numeracy teaching for a child, against Merrick's advice.
Staff measure the success of the three current pupils, and seven others who have attended the school, in a number of ways. The organisation's mere survival is one indicator: Common Thread and Merrick receive no grants; all income comes from charging local authorities who choose to place children with them.
Then there are the young people who have gone on to vocational training at Dumfries and Galloway College, and the reduced incidents of angry "kick- offs". Children are going to youth clubs and not being excluded any more. Perhaps the most important sign of success, Amy says, is seeing young people becoming part of the wider community.
Gordon asked if he could go to Merrick. This was a milestone for a boy who once saw school as an alien place that fuelled his anger and sapped his self-belief. Simply by attending, Merrick pupils have won a potentially life-changing battle.
"They are trying to learn when they've got all these things going on in their lives," Julie says. "We see these young people as being really remarkable."
Pupils' names have been changed.