Dumfries Prison has been praised for its moves to deal with issues raised in a critical report by inspectors.
Improvements at the prison are said to have come at a price
The chief inspector of prisons said a sense of purpose, focus and motivation was making a significant impact.
A previous report had highlighted out-of-date procedures and old-fashioned equipment at the jail.
Most of those problems had now been addressed, although concerns remained about the conditions in which remand prisoners were kept, the report said.
Dr Andrew McLellan highlighted a number of areas of improvement in his report.
"Dumfries Prison has responded well to the inspection report of 2005," he said.
"An impressive number of concerns raised have been addressed and resolved completely.
Areas of improvement at Dumfries Prison
Better use of anti-suicide measures
Access to a more productive day for most prisoners
Better sentence management for long-term prisoners
Greater consistency in the quality of induction
Improvements to the complaints system
Better access to health care
"Prisoners and staff alike drew attention to the sense of purpose, focus and motivation making a significant impact on the prison."
Dr McLellan said the arrival of sex offenders at the prison from Peterhead in 2004 had been well managed, as the previous report had shown.
"At the time of the last report, however, there was little evidence that the prison had addressed the needs of that population," he said.
"That is no longer true, and this report shows that there has been significant improvement in provision for long-term sex offenders.
"However, improvement has come at a price.
"It is to the credit of the Scottish Prison Service that they had, until recently, tried to hold remand prisoners in the best accommodation.
"But now remand prisoners spend long hours locked in their cells, have no access to work and very little access to education.
"The prison is fulfilling the terms of its contract, but the conditions of remand prisoners are not good."
Another issue highlighted was the closure of the women's unit in Dumfries with prisoners now being taken to Cornton Vale in Stirling.
"The report recognises that closing the unit has brought real advantages," said Dr McLellan.
"But it also recognises that women who are imprisoned many miles from their families, particularly those imprisoned for a short time, are likely to be disadvantaged."
Finally, the chief inspector said he had examined an increase in complaints but come to the conclusion they did not indicate a deterioration of conditions.
"It represents a change in the attitudes of prisoners towards the complaints system," he said.