Doc and memory cleanup.