Post variable cleanup and memory leak fix.