More memory wrapper and cleanup work. #6226 w/one very minor compile fix mod in...