Code cleanup and enhancements Pdf Document