Changed how graphics are handled by knitr to be more elegant and require less code