Bunch of stuff to make PDF reports work reasonably well