Added logging and displaying of stack trace