Use AutoPtr in those cases where release() is used re #8485

Signed-off-by: Karl Palmen <karl.palmen@stfc.ac.uk>