Added more report parameters and made code more failsafe.