Fix a memory leak and remove unncessary indirection from an internal
function.