A prison has been praised for its efforts to prevent suicide among its inmates but some concerns remain about its operation, say inspectors.
An inspection of HMP Cardiff, which has seen a spate of deaths in custody in recent months, also found it "on top" of prisoners' drug problems.
But it called for more attention to vulnerable inmates, cleanliness and time prisoners spent out of cells.
The deputy chief inspector of prisons said the report was generally positive.
In his report Nigel Newcomen said the unannounced inspection of HMP Cardiff on 28-30 June 2010 found it was managing a range of challenging issues.
But it remained a safe purposeful place, appropriately focused on its resettlement role.
HM Inspectorate of Prisons found that like many prisons, it had to manage issues such as overcrowding, an ageing infrastructure and often needy and sometimes challenging short-term prisoners.
After a spate of deaths in custody at Cardiff during the past 18 months, the report said the inspectors were pleased to find that an appropriately heightened focus had been given to suicide prevention work.
He said the prison appeared to be on top of the drug problem that followed many prisoners into custody.
There was also an adequate range of work and education opportunities addressing the needs of an often needy and sometimes challenging population, the report said.
Staff-prisoner relationships were generally good; and there was a sound emphasis on resettlement with a well-resourced offender management unit.
However the inspectors were concerned that there was still too little care planning for vulnerable prisoners and those struggling to cope.
The report said the prison needed to improve its management of diversity.
The quality and cleanliness of its living accommodation varied, as did the amount of time prisoners spent out of their cell.
Mr Newcomen said: "This is a generally positive report which demonstrates that Cardiff has sustained much of the progress that we identified on our last visit, although we identify a number of areas for further improvement.
"This is commendable given the inherent challenges facing managers and staff, both in terms of the ageing, overcrowded environment of the prison, and the many risks and needs posed by the transient prisoner population."
Michael Spurr, chief executive officer of the National Offender Management Service (NOMS), said: "I am pleased that the deputy chief inspector has recognised that Cardiff has continued to make progress.
"Significant work has been done in the management of self-harm since the inspection, and the reduction of deaths in custody is always a priority. "
He added that the governor and staff were maintaining a "safe and respectful environment" with a strong focus on resettlement which was especially important.
This reduced the likelihood of re-offending and helped to protect the public, he said.
HMP Cardiff holds adult male convicted and remand prisoners and those awaiting sentence. It holds both category B and C prisoners, and also provides a training function.
As of September 2008 it had the capacity for 784 inmates.