Fix modification for pdf rendering, clean code