Added more debug output if an exception occurs