Plenty of polish

Almost ready for deployment. The issue when creating the PDF remain.
Cleaning up the code