Index: classes/DelphesPileUpReader.cc
===================================================================
--- classes/DelphesPileUpReader.cc	(revision f25215c683347e1cf224b96bcc5bfc8f78ac792b)
+++ classes/DelphesPileUpReader.cc	(revision 3d19203972fca8b5048cc2ba92ecc922f555ed0b)
@@ -33,6 +33,7 @@
 
 #include <stdio.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
+#include <stdint.h>
+
+#include "classes/DelphesXDRReader.h"
 
 using namespace std;
@@ -47,15 +48,16 @@
   fEntries(0), fEntrySize(0), fCounter(0),
   fPileUpFile(0), fIndex(0), fBuffer(0),
-  fInputXDR(0), fIndexXDR(0), fBufferXDR(0)
+  fInputReader(0), fIndexReader(0), fBufferReader(0)
 {
   stringstream message;
 
-  fIndex = new char[kIndexSize*8];
-  fBuffer = new char[kBufferSize*kRecordSize*4];
-  fInputXDR = new XDR;
-  fIndexXDR = new XDR;
-  fBufferXDR = new XDR;
-  xdrmem_create(fIndexXDR, fIndex, kIndexSize*8, XDR_DECODE);
-  xdrmem_create(fBufferXDR, fBuffer, kBufferSize*kRecordSize*4, XDR_DECODE);
+  fIndex = new uint8_t[kIndexSize*8];
+  fBuffer = new uint8_t[kBufferSize*kRecordSize*4];
+  fInputReader = new DelphesXDRReader;
+  fIndexReader = new DelphesXDRReader;
+  fBufferReader = new DelphesXDRReader;
+
+  fIndexReader->SetBuffer(fIndex);
+  fBufferReader->SetBuffer(fBuffer);
 
   fPileUpFile = fopen(fileName, "r");
@@ -67,9 +69,9 @@
   }
 
-  xdrstdio_create(fInputXDR, fPileUpFile, XDR_DECODE);
+  fInputReader->SetFile(fPileUpFile);
 
   // read number of events
   fseeko(fPileUpFile, -8, SEEK_END);
-  xdr_hyper(fInputXDR, &fEntries);
+  fInputReader->ReadValue(&fEntries, 8);
 
   if(fEntries >= kIndexSize)
@@ -81,5 +83,5 @@
   // read index of events
   fseeko(fPileUpFile, -8 - 8*fEntries, SEEK_END);
-  xdr_opaque(fInputXDR, fIndex, fEntries*8);
+  fInputReader->ReadRaw(fIndex, fEntries*8);
 }
 
@@ -88,11 +90,8 @@
 DelphesPileUpReader::~DelphesPileUpReader()
 {
-  xdr_destroy(fInputXDR);
   if(fPileUpFile) fclose(fPileUpFile);
-  xdr_destroy(fBufferXDR);
-  xdr_destroy(fIndexXDR);
-  if(fBufferXDR) delete fBufferXDR;
-  if(fIndexXDR) delete fIndexXDR;
-  if(fInputXDR) delete fInputXDR;
+  if(fBufferReader) delete fBufferReader;
+  if(fIndexReader) delete fIndexReader;
+  if(fInputReader) delete fInputReader;
   if(fBuffer) delete[] fBuffer;
   if(fIndex) delete[] fIndex;
@@ -101,5 +100,5 @@
 //------------------------------------------------------------------------------
 
-bool DelphesPileUpReader::ReadParticle(int &pid,
+bool DelphesPileUpReader::ReadParticle(int32_t &pid,
   float &x, float &y, float &z, float &t,
   float &px, float &py, float &pz, float &e)
@@ -107,13 +106,13 @@
   if(fCounter >= fEntrySize) return false;
 
-  xdr_int(fBufferXDR, &pid);
-  xdr_float(fBufferXDR, &x);
-  xdr_float(fBufferXDR, &y);
-  xdr_float(fBufferXDR, &z);
-  xdr_float(fBufferXDR, &t);
-  xdr_float(fBufferXDR, &px);
-  xdr_float(fBufferXDR, &py);
-  xdr_float(fBufferXDR, &pz);
-  xdr_float(fBufferXDR, &e);
+  fBufferReader->ReadValue(&pid, 4);
+  fBufferReader->ReadValue(&x, 4);
+  fBufferReader->ReadValue(&y, 4);
+  fBufferReader->ReadValue(&z, 4);
+  fBufferReader->ReadValue(&t, 4);
+  fBufferReader->ReadValue(&px, 4);
+  fBufferReader->ReadValue(&py, 4);
+  fBufferReader->ReadValue(&pz, 4);
+  fBufferReader->ReadValue(&e, 4);
 
   ++fCounter;
@@ -124,17 +123,17 @@
 //------------------------------------------------------------------------------
 
-bool DelphesPileUpReader::ReadEntry(quad_t entry)
+bool DelphesPileUpReader::ReadEntry(int64_t entry)
 {
-  quad_t offset;
+  int64_t offset;
 
   if(entry >= fEntries) return false;
 
   // read event position
-  xdr_setpos(fIndexXDR, 8*entry);
-  xdr_hyper(fIndexXDR, &offset);
+  fIndexReader->SetOffset(8*entry);
+  fIndexReader->ReadValue(&offset, 8);
 
   // read event
   fseeko(fPileUpFile, offset, SEEK_SET);
-  xdr_int(fInputXDR, &fEntrySize);
+  fInputReader->ReadValue(&fEntrySize, 4);
 
   if(fEntrySize >= kBufferSize)
@@ -143,6 +142,6 @@
   }
 
-  xdr_opaque(fInputXDR, fBuffer, fEntrySize*kRecordSize*4);
-  xdr_setpos(fBufferXDR, 0);
+  fInputReader->ReadRaw(fBuffer, fEntrySize*kRecordSize*4);
+  fBufferReader->SetOffset(0);
   fCounter = 0;
 
Index: classes/DelphesPileUpReader.h
===================================================================
--- classes/DelphesPileUpReader.h	(revision f25215c683347e1cf224b96bcc5bfc8f78ac792b)
+++ classes/DelphesPileUpReader.h	(revision 3d19203972fca8b5048cc2ba92ecc922f555ed0b)
@@ -29,6 +29,7 @@
 
 #include <stdio.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
+#include <stdint.h>
+
+class DelphesXDRReader;
 
 class DelphesPileUpReader
@@ -40,29 +41,27 @@
   ~DelphesPileUpReader();
 
-  bool ReadParticle(int &pid,
+  bool ReadParticle(int32_t &pid,
     float &x, float &y, float &z, float &t,
     float &px, float &py, float &pz, float &e);
 
-  bool ReadEntry(quad_t entry);
+  bool ReadEntry(int64_t entry);
 
-  quad_t GetEntries() const { return fEntries; }
+  int64_t GetEntries() const { return fEntries; }
 
 private:
 
-  quad_t fEntries;
+  int64_t fEntries;
 
-  int fEntrySize;
-  int fCounter;
+  int32_t fEntrySize;
+  int32_t fCounter;
 
   FILE *fPileUpFile;
-  char *fIndex;
-  char *fBuffer;
+  uint8_t *fIndex;
+  uint8_t *fBuffer;
 
-  XDR *fInputXDR;
-  XDR *fIndexXDR;
-  XDR *fBufferXDR;
+  DelphesXDRReader *fInputReader;
+  DelphesXDRReader *fIndexReader;
+  DelphesXDRReader *fBufferReader;
 };
 
 #endif // DelphesPileUpReader_h
-
-
Index: classes/DelphesPileUpWriter.cc
===================================================================
--- classes/DelphesPileUpWriter.cc	(revision f25215c683347e1cf224b96bcc5bfc8f78ac792b)
+++ classes/DelphesPileUpWriter.cc	(revision 3d19203972fca8b5048cc2ba92ecc922f555ed0b)
@@ -33,6 +33,7 @@
 
 #include <stdio.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
+#include <stdint.h>
+
+#include "classes/DelphesXDRWriter.h"
 
 using namespace std;
@@ -47,15 +48,16 @@
   fEntries(0), fEntrySize(0), fOffset(0),
   fPileUpFile(0), fIndex(0), fBuffer(0),
-  fOutputXDR(0), fIndexXDR(0), fBufferXDR(0)
+  fOutputWriter(0), fIndexWriter(0), fBufferWriter(0)
 {
   stringstream message;
 
-  fIndex = new char[kIndexSize*8];
-  fBuffer = new char[kBufferSize*kRecordSize*4];
-  fOutputXDR = new XDR;
-  fIndexXDR = new XDR;
-  fBufferXDR = new XDR;
-  xdrmem_create(fIndexXDR, fIndex, kIndexSize*8, XDR_ENCODE);
-  xdrmem_create(fBufferXDR, fBuffer, kBufferSize*kRecordSize*4, XDR_ENCODE);
+  fIndex = new uint8_t[kIndexSize*8];
+  fBuffer = new uint8_t[kBufferSize*kRecordSize*4];
+  fOutputWriter = new DelphesXDRWriter;
+  fIndexWriter = new DelphesXDRWriter;
+  fBufferWriter = new DelphesXDRWriter;
+
+  fIndexWriter->SetBuffer(fIndex);
+  fBufferWriter->SetBuffer(fBuffer);
 
   fPileUpFile = fopen(fileName, "w+");
@@ -67,5 +69,5 @@
   }
 
-  xdrstdio_create(fOutputXDR, fPileUpFile, XDR_ENCODE);
+  fOutputWriter->SetFile(fPileUpFile);
 }
 
@@ -74,11 +76,8 @@
 DelphesPileUpWriter::~DelphesPileUpWriter()
 {
-  xdr_destroy(fOutputXDR);
   if(fPileUpFile) fclose(fPileUpFile);
-  xdr_destroy(fBufferXDR);
-  xdr_destroy(fIndexXDR);
-  if(fBufferXDR) delete fBufferXDR;
-  if(fIndexXDR) delete fIndexXDR;
-  if(fOutputXDR) delete fOutputXDR;
+  if(fBufferWriter) delete fBufferWriter;
+  if(fIndexWriter) delete fIndexWriter;
+  if(fOutputWriter) delete fOutputWriter;
   if(fBuffer) delete[] fBuffer;
   if(fIndex) delete[] fIndex;
@@ -87,5 +86,5 @@
 //------------------------------------------------------------------------------
 
-void DelphesPileUpWriter::WriteParticle(int pid,
+void DelphesPileUpWriter::WriteParticle(int32_t pid,
   float x, float y, float z, float t,
   float px, float py, float pz, float e)
@@ -96,13 +95,13 @@
   }
 
-  xdr_int(fBufferXDR, &pid);
-  xdr_float(fBufferXDR, &x);
-  xdr_float(fBufferXDR, &y);
-  xdr_float(fBufferXDR, &z);
-  xdr_float(fBufferXDR, &t);
-  xdr_float(fBufferXDR, &px);
-  xdr_float(fBufferXDR, &py);
-  xdr_float(fBufferXDR, &pz);
-  xdr_float(fBufferXDR, &e);
+  fBufferWriter->WriteValue(&pid, 4);
+  fBufferWriter->WriteValue(&x, 4);
+  fBufferWriter->WriteValue(&y, 4);
+  fBufferWriter->WriteValue(&z, 4);
+  fBufferWriter->WriteValue(&t, 4);
+  fBufferWriter->WriteValue(&px, 4);
+  fBufferWriter->WriteValue(&py, 4);
+  fBufferWriter->WriteValue(&pz, 4);
+  fBufferWriter->WriteValue(&e, 4);
 
   ++fEntrySize;
@@ -118,13 +117,13 @@
   }
 
-  xdr_int(fOutputXDR, &fEntrySize);
-  xdr_opaque(fOutputXDR, fBuffer, fEntrySize*kRecordSize*4);
+  fOutputWriter->WriteValue(&fEntrySize, 4);
+  fOutputWriter->WriteRaw(fBuffer, fEntrySize*kRecordSize*4);
 
-  xdr_hyper(fIndexXDR, &fOffset);
+  fIndexWriter->WriteValue(&fOffset, 8);
   fOffset += fEntrySize*kRecordSize*4 + 4;
 
-  xdr_setpos(fBufferXDR, 0);
+  fBufferWriter->SetOffset(0);
   fEntrySize = 0;
-        
+
   ++fEntries;
 }
@@ -134,6 +133,6 @@
 void DelphesPileUpWriter::WriteIndex()
 {
-  xdr_opaque(fOutputXDR, fIndex, fEntries*8);
-  xdr_hyper(fOutputXDR, &fEntries);
+  fOutputWriter->WriteRaw(fIndex, fEntries*8);
+  fOutputWriter->WriteValue(&fEntries, 8);
 }
 
Index: classes/DelphesPileUpWriter.h
===================================================================
--- classes/DelphesPileUpWriter.h	(revision f25215c683347e1cf224b96bcc5bfc8f78ac792b)
+++ classes/DelphesPileUpWriter.h	(revision 3d19203972fca8b5048cc2ba92ecc922f555ed0b)
@@ -29,6 +29,7 @@
 
 #include <stdio.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
+#include <stdint.h>
+
+class DelphesXDRWriter;
 
 class DelphesPileUpWriter
@@ -40,5 +41,5 @@
   ~DelphesPileUpWriter();
 
-  void WriteParticle(int pid,
+  void WriteParticle(int32_t pid,
     float x, float y, float z, float t,
     float px, float py, float pz, float e);
@@ -50,18 +51,16 @@
 private:
 
-  quad_t fEntries;
-  int fEntrySize;
-  quad_t fOffset;
+  int64_t fEntries;
+  int32_t fEntrySize;
+  int64_t fOffset;
 
   FILE *fPileUpFile;
-  char *fIndex;
-  char *fBuffer;
+  uint8_t *fIndex;
+  uint8_t *fBuffer;
 
-  XDR *fOutputXDR;
-  XDR *fIndexXDR;
-  XDR *fBufferXDR;
+  DelphesXDRWriter *fOutputWriter;
+  DelphesXDRWriter *fIndexWriter;
+  DelphesXDRWriter *fBufferWriter;
 };
 
 #endif // DelphesPileUpWriter_h
-
-
Index: classes/DelphesSTDHEPReader.cc
===================================================================
--- classes/DelphesSTDHEPReader.cc	(revision f25215c683347e1cf224b96bcc5bfc8f78ac792b)
+++ classes/DelphesSTDHEPReader.cc	(revision 3d19203972fca8b5048cc2ba92ecc922f555ed0b)
@@ -34,6 +34,6 @@
 #include <stdio.h>
 #include <errno.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
+#include <stdint.h>
+#include <string.h>
 
 #include "TObjArray.h"
@@ -45,4 +45,5 @@
 #include "classes/DelphesClasses.h"
 #include "classes/DelphesFactory.h"
+#include "classes/DelphesXDRReader.h"
 
 #include "ExRootAnalysis/ExRootTreeBranch.h"
@@ -55,8 +56,7 @@
 
 DelphesSTDHEPReader::DelphesSTDHEPReader() :
-  fInputFile(0), fInputXDR(0), fBuffer(0), fPDG(0), fBlockType(-1)
-{
-  fInputXDR = new XDR;
-  fBuffer = new char[kBufferSize*96 + 24];
+  fInputFile(0), fBuffer(0), fPDG(0), fBlockType(-1)
+{
+  fBuffer = new uint8_t[kBufferSize*96 + 24];
 
   fPDG = TDatabasePDG::Instance();
@@ -68,5 +68,4 @@
 {
   if(fBuffer) delete fBuffer;
-  if(fInputXDR) delete fInputXDR;
 }
 
@@ -76,5 +75,5 @@
 {
   fInputFile = inputFile;
-  xdrstdio_create(fInputXDR, inputFile, XDR_DECODE);
+  fReader[0].SetFile(inputFile);
 }
 
@@ -100,7 +99,7 @@
   TObjArray *partonOutputArray)
 {
+  fReader[0].ReadValue(&fBlockType, 4);
+
   if(feof(fInputFile)) return kFALSE;
-
-  xdr_int(fInputXDR, &fBlockType);
 
   SkipBytes(4);
@@ -146,8 +145,8 @@
 //---------------------------------------------------------------------------
 
-void DelphesSTDHEPReader::SkipBytes(u_int size)
+void DelphesSTDHEPReader::SkipBytes(int size)
 {
   int rc;
-  u_int rndup;
+  int rndup;
 
   rndup = size % 4;
@@ -161,14 +160,14 @@
   if(rc != 0 && errno == ESPIPE)
   {
-    xdr_opaque(fInputXDR, fBuffer, size);
-  }
-}
-
-//---------------------------------------------------------------------------
-
-void DelphesSTDHEPReader::SkipArray(u_int elsize)
-{
-  u_int size;
-  xdr_u_int(fInputXDR, &size);
+    fReader[0].ReadRaw(fBuffer, size);
+  }
+}
+
+//---------------------------------------------------------------------------
+
+void DelphesSTDHEPReader::SkipArray(int elsize)
+{
+  uint32_t size;
+  fReader[0].ReadValue(&size, 4);
   SkipBytes(size*elsize);
 }
@@ -178,12 +177,12 @@
 void DelphesSTDHEPReader::ReadFileHeader()
 {
-  u_int i;
+  uint32_t i;
   enum STDHEPVersion {UNKNOWN, V1, V2, V21} version;
 
   // version
-  xdr_string(fInputXDR, &fBuffer, 100);
+  fReader[0].ReadString(fBuffer, 100);
   if(fBuffer[0] == '\0' || fBuffer[1] == '\0') version = UNKNOWN;
   else if(fBuffer[0] == '1') version = V1;
-  else if(strncmp(fBuffer, "2.01", 4) == 0) version = V21;
+  else if(strncmp((char *)fBuffer, "2.01", 4) == 0) version = V21;
   else if(fBuffer[0] == '2') version = V2;
   else version = UNKNOWN;
@@ -207,17 +206,17 @@
 
   // Number of events
-  xdr_u_int(fInputXDR, &fEntries);
+  fReader[0].ReadValue(&fEntries, 4);
 
   SkipBytes(8);
 
   // Number of blocks
-  u_int nBlocks = 0;
-  xdr_u_int(fInputXDR, &nBlocks);
+  uint32_t nBlocks = 0;
+  fReader[0].ReadValue(&nBlocks, 4);
 
   // Number of NTuples
-  u_int nNTuples = 0;
+  uint32_t nNTuples = 0;
   if(version != V1)
   {
-    xdr_u_int(fInputXDR, &nNTuples);
+    fReader[0].ReadValue(&nNTuples, 4);
   }
 
@@ -244,6 +243,6 @@
 {
   // version
-  xdr_string(fInputXDR, &fBuffer, 100);
-  if(strncmp(fBuffer, "1.00", 4) == 0)
+  fReader[0].ReadString(fBuffer, 100);
+  if(strncmp((char *)fBuffer, "1.00", 4) == 0)
   {
     SkipBytes(8);
@@ -255,5 +254,5 @@
     SkipArray(4);
   }
-  else if(strncmp(fBuffer, "2.00", 4) == 0)
+  else if(strncmp((char *)fBuffer, "2.00", 4) == 0)
   {
     SkipBytes(12);
@@ -272,13 +271,13 @@
 {
   bool skipNTuples = false;
-  u_int skipSize = 4;
+  int skipSize = 4;
 
   // version
-  xdr_string(fInputXDR, &fBuffer, 100);
-  if(strncmp(fBuffer, "2.00", 4) == 0)
+  fReader[0].ReadString(fBuffer, 100);
+  if(strncmp((char *)fBuffer, "2.00", 4) == 0)
   {
     skipNTuples = true;
   }
-  else if(strncmp(fBuffer, "3.00", 4) == 0)
+  else if(strncmp((char *)fBuffer, "3.00", 4) == 0)
   {
     skipNTuples = true;
@@ -288,12 +287,12 @@
   SkipBytes(20);
 
-  u_int dimBlocks = 0;
-  xdr_u_int(fInputXDR, &dimBlocks);
-
-  u_int dimNTuples = 0;
+  uint32_t dimBlocks = 0;
+  fReader[0].ReadValue(&dimBlocks, 4);
+
+  uint32_t dimNTuples = 0;
   if(skipNTuples)
   {
     SkipBytes(4);
-    xdr_u_int(fInputXDR, &dimNTuples);
+    fReader[0].ReadValue(&dimNTuples, 4);
   }
 
@@ -318,12 +317,12 @@
 {
   // version
-  xdr_string(fInputXDR, &fBuffer, 100);
+  fReader[0].ReadString(fBuffer, 100);
 
   // skip 5*4 + 2*8 = 36 bytes
   SkipBytes(36);
 
-  if((strncmp(fBuffer, "1.", 2) == 0) || (strncmp(fBuffer, "2.", 2) == 0) ||
-     (strncmp(fBuffer, "3.", 2) == 0) || (strncmp(fBuffer, "4.", 2) == 0) ||
-     (strncmp(fBuffer, "5.00", 4) == 0))
+  if((strncmp((char *)fBuffer, "1.", 2) == 0) || (strncmp((char *)fBuffer, "2.", 2) == 0) ||
+     (strncmp((char *)fBuffer, "3.", 2) == 0) || (strncmp((char *)fBuffer, "4.", 2) == 0) ||
+     (strncmp((char *)fBuffer, "5.00", 4) == 0))
   {
     return;
@@ -333,5 +332,5 @@
   SkipArray(1);
 
-  if(strncmp(fBuffer, "5.01", 4) == 0)
+  if(strncmp((char *)fBuffer, "5.01", 4) == 0)
   {
     return;
@@ -345,14 +344,14 @@
 void DelphesSTDHEPReader::ReadSTDHEP()
 {
-  u_int idhepSize, isthepSize, jmohepSize, jdahepSize, phepSize, vhepSize;
+  uint32_t idhepSize, isthepSize, jmohepSize, jdahepSize, phepSize, vhepSize;
 
   // version
-  xdr_string(fInputXDR, &fBuffer, 100);
+  fReader[0].ReadString(fBuffer, 100);
 
   // Extracting the event number
-  xdr_int(fInputXDR, &fEventNumber);
+  fReader[0].ReadValue(&fEventNumber, 4);
 
   // Extracting the number of particles
-  xdr_int(fInputXDR, &fEventSize);
+  fReader[0].ReadValue(&fEventSize, 4);
 
   if(fEventSize >= kBufferSize)
@@ -364,12 +363,19 @@
   // 4 + 4 + 4 + 4 + 4 + 4 = 96*n + 24
 
-  xdr_opaque(fInputXDR, fBuffer, 96*fEventSize + 24);
-
-  idhepSize = ntohl(*(u_int*)(fBuffer));
-  isthepSize = ntohl(*(u_int*)(fBuffer + 4*1 + 4*1*fEventSize));
-  jmohepSize = ntohl(*(u_int*)(fBuffer + 4*2 + 4*2*fEventSize));
-  jdahepSize = ntohl(*(u_int*)(fBuffer + 4*3 + 4*4*fEventSize));
-  phepSize = ntohl(*(u_int*)(fBuffer + 4*4 + 4*6*fEventSize));
-  vhepSize = ntohl(*(u_int*)(fBuffer + 4*5 + 4*16*fEventSize));
+  fReader[0].ReadRaw(fBuffer, 96*fEventSize + 24);
+
+  fReader[1].SetBuffer(fBuffer);
+  fReader[2].SetBuffer(fBuffer + 4*1 + 4*1*fEventSize);
+  fReader[3].SetBuffer(fBuffer + 4*2 + 4*2*fEventSize);
+  fReader[4].SetBuffer(fBuffer + 4*3 + 4*4*fEventSize);
+  fReader[5].SetBuffer(fBuffer + 4*4 + 4*6*fEventSize);
+  fReader[6].SetBuffer(fBuffer + 4*5 + 4*16*fEventSize);
+
+  fReader[1].ReadValue(&idhepSize, 4);
+  fReader[2].ReadValue(&isthepSize, 4);
+  fReader[3].ReadValue(&jmohepSize, 4);
+  fReader[4].ReadValue(&jdahepSize, 4);
+  fReader[5].ReadValue(&phepSize, 4);
+  fReader[6].ReadValue(&vhepSize, 4);
 
   if(fEventSize < 0 ||
@@ -392,20 +398,20 @@
 void DelphesSTDHEPReader::ReadSTDHEP4()
 {
-  u_int number;
+  uint32_t number;
 
   // Extracting the event weight
-  xdr_double(fInputXDR, &fWeight);
+  fReader[0].ReadValue(&fWeight, 8);
 
   // Extracting alpha QED
-  xdr_double(fInputXDR, &fAlphaQED);
+  fReader[0].ReadValue(&fAlphaQED, 8);
 
   // Extracting alpha QCD
-  xdr_double(fInputXDR, &fAlphaQCD);
+  fReader[0].ReadValue(&fAlphaQCD, 8);
 
   // Extracting the event scale
-  xdr_u_int(fInputXDR, &fScaleSize);
+  fReader[0].ReadValue(&fScaleSize, 4);
   for(number = 0; number < fScaleSize; ++number)
   {
-    xdr_double(fInputXDR, &fScale[number]);
+    fReader[0].ReadValue(&fScale[number], 8);
   }
 
@@ -450,35 +456,27 @@
 
   int number;
-  int pid, status, m1, m2, d1, d2;
+  int32_t pid, status, m1, m2, d1, d2;
   double px, py, pz, e, mass;
   double x, y, z, t;
 
-  XDR bufferXDR[6];
-  xdrmem_create(&bufferXDR[0], fBuffer + 4*1, 4*fEventSize, XDR_DECODE);
-  xdrmem_create(&bufferXDR[1], fBuffer + 4*2 + 4*1*fEventSize, 4*fEventSize, XDR_DECODE);
-  xdrmem_create(&bufferXDR[2], fBuffer + 4*3 + 4*2*fEventSize, 8*fEventSize, XDR_DECODE);
-  xdrmem_create(&bufferXDR[3], fBuffer + 4*4 + 4*4*fEventSize, 8*fEventSize, XDR_DECODE);
-  xdrmem_create(&bufferXDR[4], fBuffer + 4*5 + 4*6*fEventSize, 40*fEventSize, XDR_DECODE);
-  xdrmem_create(&bufferXDR[5], fBuffer + 4*6 + 4*16*fEventSize, 32*fEventSize, XDR_DECODE);
-
   for(number = 0; number < fEventSize; ++number)
   {
-    xdr_int(&bufferXDR[0], &status);
-    xdr_int(&bufferXDR[1], &pid);
-    xdr_int(&bufferXDR[2], &m1);
-    xdr_int(&bufferXDR[2], &m2);
-    xdr_int(&bufferXDR[3], &d1);
-    xdr_int(&bufferXDR[3], &d2);
-
-    xdr_double(&bufferXDR[4], &px);
-    xdr_double(&bufferXDR[4], &py);
-    xdr_double(&bufferXDR[4], &pz);
-    xdr_double(&bufferXDR[4], &e);
-    xdr_double(&bufferXDR[4], &mass);
-
-    xdr_double(&bufferXDR[5], &x);
-    xdr_double(&bufferXDR[5], &y);
-    xdr_double(&bufferXDR[5], &z);
-    xdr_double(&bufferXDR[5], &t);
+    fReader[1].ReadValue(&status, 4);
+    fReader[2].ReadValue(&pid, 4);
+    fReader[3].ReadValue(&m1, 4);
+    fReader[3].ReadValue(&m2, 4);
+    fReader[4].ReadValue(&d1, 4);
+    fReader[4].ReadValue(&d2, 4);
+
+    fReader[5].ReadValue(&px, 8);
+    fReader[5].ReadValue(&py, 8);
+    fReader[5].ReadValue(&pz, 8);
+    fReader[5].ReadValue(&e, 8);
+    fReader[5].ReadValue(&mass, 8);
+
+    fReader[6].ReadValue(&x, 8);
+    fReader[6].ReadValue(&y, 8);
+    fReader[6].ReadValue(&z, 8);
+    fReader[6].ReadValue(&t, 8);
 
     candidate = factory->NewCandidate();
Index: classes/DelphesSTDHEPReader.h
===================================================================
--- classes/DelphesSTDHEPReader.h	(revision f25215c683347e1cf224b96bcc5bfc8f78ac792b)
+++ classes/DelphesSTDHEPReader.h	(revision 3d19203972fca8b5048cc2ba92ecc922f555ed0b)
@@ -29,6 +29,7 @@
 
 #include <stdio.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
+#include <stdint.h>
+
+#include "classes/DelphesXDRReader.h"
 
 class TObjArray;
@@ -37,4 +38,5 @@
 class ExRootTreeBranch;
 class DelphesFactory;
+class DelphesXDRReader;
 
 class DelphesSTDHEPReader
@@ -76,6 +78,6 @@
     TObjArray *partonOutputArray);
 
-  void SkipBytes(u_int size);
-  void SkipArray(u_int elsize);
+  void SkipBytes(int size);
+  void SkipArray(int elsize);
 
   void ReadFileHeader();
@@ -88,19 +90,17 @@
   FILE *fInputFile;
 
-  XDR *fInputXDR;
+  DelphesXDRReader fReader[7];
 
-  char *fBuffer;
+  uint8_t *fBuffer;
 
   TDatabasePDG *fPDG;
 
-  u_int fEntries;
-  int fBlockType, fEventNumber, fEventSize;
+  uint32_t fEntries;
+  int32_t fBlockType, fEventNumber, fEventSize;
   double fWeight, fAlphaQCD, fAlphaQED;
 
-  u_int fScaleSize;
+  uint32_t fScaleSize;
   double fScale[10];
 };
 
 #endif // DelphesSTDHEPReader_h
-
-
Index: classes/DelphesXDRReader.cc
===================================================================
--- classes/DelphesXDRReader.cc	(revision 3d19203972fca8b5048cc2ba92ecc922f555ed0b)
+++ classes/DelphesXDRReader.cc	(revision 3d19203972fca8b5048cc2ba92ecc922f555ed0b)
@@ -0,0 +1,123 @@
+/*
+ *  Delphes: a framework for fast simulation of a generic collider experiment
+ *  Copyright (C) 2018  Universite catholique de Louvain (UCL), Belgium
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+/** \class DelphesXDRReader
+ *
+ *  Reads XDR
+ *
+ *  \author P. Demin - UCL, Louvain-la-Neuve
+ *
+ */
+
+#include "classes/DelphesXDRReader.h"
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+
+//------------------------------------------------------------------------------
+
+DelphesXDRReader::DelphesXDRReader() :
+  fFile(0), fBuffer(0), fOffset(0)
+{
+}
+
+//------------------------------------------------------------------------------
+
+void DelphesXDRReader::SetFile(FILE *file)
+{
+  fFile = file;
+}
+
+//------------------------------------------------------------------------------
+
+void DelphesXDRReader::SetBuffer(void *buffer)
+{
+  fBuffer = (uint8_t *)buffer;
+  fOffset = 0;
+}
+
+//------------------------------------------------------------------------------
+
+void DelphesXDRReader::SetOffset(int offset)
+{
+  fOffset = offset;
+}
+
+//------------------------------------------------------------------------------
+
+void DelphesXDRReader::ReadRaw(void *value, int size)
+{
+  int rndup;
+
+  rndup = size % 4;
+  if(rndup > 0)
+  {
+    rndup = 4 - rndup;
+  }
+
+  if(fFile)
+  {
+    fread(value, 1, size + rndup, fFile);
+  }
+}
+
+//------------------------------------------------------------------------------
+
+void DelphesXDRReader::ReadValue(void *value, int size)
+{
+  int i;
+  uint8_t *dst, buffer[8];
+
+  dst = (uint8_t *)value;
+
+  if(fBuffer)
+  {
+    fOffset += size;
+    for(i = 0; i < size; ++i) dst[i] = fBuffer[fOffset - 1 - i];
+  }
+  else if(fFile)
+  {
+    ReadRaw(buffer, size);
+    for(i = 0; i < size; ++i) dst[i] = buffer[size - 1 - i];
+  }
+}
+
+//------------------------------------------------------------------------------
+
+void DelphesXDRReader::ReadString(void *value, int maxSize)
+{
+  int32_t size;
+
+  ReadValue(&size, 4);
+
+  if(size > maxSize) size = maxSize;
+    
+  if(fBuffer)
+  {
+    memcpy(value, fBuffer + fOffset, size);
+    fOffset += size;
+  }
+  else if(fFile)
+  {
+    ReadRaw(value, size);
+  }
+}
+
+//------------------------------------------------------------------------------
Index: classes/DelphesXDRReader.h
===================================================================
--- classes/DelphesXDRReader.h	(revision 3d19203972fca8b5048cc2ba92ecc922f555ed0b)
+++ classes/DelphesXDRReader.h	(revision 3d19203972fca8b5048cc2ba92ecc922f555ed0b)
@@ -0,0 +1,55 @@
+/*
+ *  Delphes: a framework for fast simulation of a generic collider experiment
+ *  Copyright (C) 2018  Universite catholique de Louvain (UCL), Belgium
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef DelphesXDRReader_h
+#define DelphesXDRReader_h
+
+/** \class DelphesXDRReader
+ *
+ *  Reads XDR
+ *
+ *  \author P. Demin - UCL, Louvain-la-Neuve
+ *
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+
+class DelphesXDRReader
+{
+public:
+
+  DelphesXDRReader();
+
+  void SetFile(FILE *file);
+  void SetBuffer(void *buffer);
+  void SetOffset(int offset);
+
+  void ReadRaw(void *value, int size);
+  void ReadValue(void *value, int size);
+  void ReadString(void *value, int maxSize);
+
+private:
+
+  FILE *fFile;
+  uint8_t *fBuffer;
+
+  int fOffset;
+};
+
+#endif // DelphesXDRReader_h
Index: classes/DelphesXDRWriter.cc
===================================================================
--- classes/DelphesXDRWriter.cc	(revision 3d19203972fca8b5048cc2ba92ecc922f555ed0b)
+++ classes/DelphesXDRWriter.cc	(revision 3d19203972fca8b5048cc2ba92ecc922f555ed0b)
@@ -0,0 +1,106 @@
+/*
+ *  Delphes: a framework for fast simulation of a generic collider experiment
+ *  Copyright (C) 2018  Universite catholique de Louvain (UCL), Belgium
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+/** \class DelphesXDRWriter
+ *
+ *  Writes XDR
+ *
+ *  \author P. Demin - UCL, Louvain-la-Neuve
+ *
+ */
+
+#include "classes/DelphesXDRWriter.h"
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+
+//------------------------------------------------------------------------------
+
+DelphesXDRWriter::DelphesXDRWriter() :
+  fFile(0), fBuffer(0), fOffset(0)
+{
+}
+
+//------------------------------------------------------------------------------
+
+void DelphesXDRWriter::SetFile(FILE *file)
+{
+  fFile = file;
+}
+
+//------------------------------------------------------------------------------
+
+void DelphesXDRWriter::SetBuffer(void *buffer)
+{
+  fBuffer = (uint8_t *)buffer;
+  fOffset = 0;
+}
+
+//------------------------------------------------------------------------------
+
+void DelphesXDRWriter::SetOffset(int offset)
+{
+  fOffset = offset;
+}
+
+//------------------------------------------------------------------------------
+
+void DelphesXDRWriter::WriteRaw(void *value, int size)
+{
+  int rndup;
+
+  rndup = size % 4;
+  if(rndup > 0)
+  {
+    rndup = 4 - rndup;
+  }
+
+  if(fFile)
+  {
+    fwrite(value, 1, size + rndup, fFile);
+  }
+}
+
+//------------------------------------------------------------------------------
+
+void DelphesXDRWriter::WriteValue(void *value, int size)
+{
+  int i;
+  uint8_t *src, buffer[8];
+
+  src = (uint8_t *)value;
+
+  if(fBuffer)
+  {
+    for(i = 0; i < size; ++i) fBuffer[fOffset + i] = src[size - 1 - i];
+    fOffset += size;
+  }
+  else if(fFile)
+  {
+    for(i = 0; i < size; ++i) buffer[i] = src[size - 1 - i];
+    WriteRaw(buffer, size);
+  }
+  else
+  {
+    return;
+  }
+}
+
+//------------------------------------------------------------------------------
Index: classes/DelphesXDRWriter.h
===================================================================
--- classes/DelphesXDRWriter.h	(revision 3d19203972fca8b5048cc2ba92ecc922f555ed0b)
+++ classes/DelphesXDRWriter.h	(revision 3d19203972fca8b5048cc2ba92ecc922f555ed0b)
@@ -0,0 +1,54 @@
+/*
+ *  Delphes: a framework for fast simulation of a generic collider experiment
+ *  Copyright (C) 2018  Universite catholique de Louvain (UCL), Belgium
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef DelphesXDRWriter_h
+#define DelphesXDRWriter_h
+
+/** \class DelphesXDRWriter
+ *
+ *  Writes XDR
+ *
+ *  \author P. Demin - UCL, Louvain-la-Neuve
+ *
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+
+class DelphesXDRWriter
+{
+public:
+
+  DelphesXDRWriter();
+
+  void SetFile(FILE *file);
+  void SetBuffer(void *buffer);
+  void SetOffset(int offset);
+
+  void WriteRaw(void *value, int size);
+  void WriteValue(void *value, int size);
+
+private:
+
+  FILE *fFile;
+  uint8_t *fBuffer;
+
+  int fOffset;
+};
+
+#endif // DelphesXDRWriter_h
