Added logging of exceptions