There is "a lot of work to do" to improve rehabilitation in Scotland's criminal justice system, according to the chief inspector of prisons.

David Strang said he sees potential for progress on this issue, as he called for greater co-ordination between the various agencies involved.

He also raised concerns over the number of prisoners held on remand ahead of court proceedings and about the number of women in custody.

Mr Strang voiced his comments as he published his annual report for 2016/17, which noted that just under 7,500 people were detained in Scotland's prisons at the end of March, down slightly on the previous year.

However, he predicted that a growing number of older prisoners, those serving longer sentences and those convicted of sexual offences will continue to place pressure on the size of the prison population for some time.

Mr Strang found that Scotland has much to be proud of when it comes to its jails and the treatment of its prisoners; highlighting the "good condition" of the buildings, well-motivated staff, and respectful relationships between staff and inmates.

But in a statement accompanying the release of the report, he said: "However, if prisons are about more than just punishment there is a lot of work to do to ensure that rehabilitation is a core outcome for the criminal justice system.

"Scottish prisons cannot achieve this on their own and this is where I see the greatest potential for progress.

"Despite the development of strategies, policies and frameworks, it is not yet evident that there is the detailed co-ordination between agencies that is required to turn these plans into reality."

He called for prisoners to be given the chance to develop the "skills, knowledge and understanding to return to their community as a productive citizen".

And he found that accessing suitable accommodation is one of the biggest difficulties for people leaving prison.

"Some are able to find accommodation with family or friends, but others end up sleeping rough," the report noted.

The Scottish Government has pledged to extend the presumption against short sentences to 12 months - a move applauded by Mr Strang.

But he suggested the number of people held on remand - more than 1,100 or almost 15% of the prison population - remains too high.

"More needs to be done to reduce the number of prisoners being remanded in custody, which can be for several months," he said.

"Remand should only be used in serious cases."

The situation for women is greater, he said, with more than 21% of women in custody held on remand.

On the number of women in prison overall, the report stated: "The numbers of females held in custody appears to be stubbornly stable at around 350, with the new estate coming on line in 2020 designed with a capacity of 230 - much work is still to be done to ensure that only those requiring a custodial environment are sent to prison."

The report also expressed concern that, in many prisons, some prisoners were being confined to their cells for long periods each day, and that places on treatment programmes to address offending behaviour were limited.

Commenting on the report, Liberal Democrat justice spokesman Liam McArthur MSP said: "Scotland still has one of the largest prison populations in Europe and reoffending rates are stubbornly high.

"That is why it is so important that the Scottish Government proceeds to extend the presumption against short-term sentences to 12 months and properly resources community sentences which are proven to be far more effective."

He added: "It is also absolutely intolerable that people are still sleeping rough after their release and even reoffending solely to find a warm bed.

"Throughcare should now be extended to every single prisoner, giving them support with the likes of housing, employment and healthcare, that starts inside and seamlessly continues after their release."

A Scottish Government spokesman said: "We welcome the inspector's recognition that our prisons are generally well run and stable, with key Scottish Government priorities - including positive opportunities, promoting positive family relationships and supporting people before they leave custody as part of key rehabilitation work - all highlighted as successes.

"Ministers have made clear they want to see fewer ineffective short-term prison sentences, and greater use of robust community sentences. At the same time, we are committed to reducing the inappropriate use of remand, providing £1.5 million of funding to local authorities over the past two years to improve the provision of bail support services for women.

"The number of women in custody in Scotland has gone down in recent years and we are working with partner organisations to continue that trend by taking action to address the specific needs of women in our justice system, including the development of a new female custodial estate."