Added logging. Implemented pdf generation. More bug fixes.