Bugfixes and pdf tests