Fixes to pdf creation