fix pdf-display, handle memory leaks differently