Moved ErrObject out of loop and added more detailled debug output