Cleaned up the module and added printing for exceptions only if debugging is enabled from the config
Cleaned up the module and added printing for exceptions only if debugging is enabled from the config