 }
 
 // NOT TESTED
-void longToGMP(mpf_class &a, const long long *toAdd, const int size_toAdd, const int maxBits, const int whereWeStart) {
+void longToGMP(mpf_class &a, const long long *toAdd, const int size_toAdd, const int ownLimbSize, const int whereWeStart) {
   // Is the precision a global variable?... I assume so?
   a = mpf_class("0");
   for (int i = 0; i < size_toAdd; i++) {
-    addToGMP(a, toAdd[i], whereWeStart - (i + 1) * maxBits)
+    addToGMP(a, toAdd[i], whereWeStart - (i + 1) * ownLimbSize)
   }
 }
 

  
  // Define the maximum no of bits we can store in a 64-bit variable 
  // and the exponent to which we should pad one (or none) of the no
  int maxBits = DOUBLE_MANT/2;
  int maxExp = max(a.get_mpf_t()->_m_exp, b.get_mpf_t()->_m_exp);
  generateLongsFromGMP(a, aS, size_aS, maxBits, maxExp);
  generateLongsFromGMP(b, bS, size_bS, maxBits, maxExp);
  int size = min(size_aS, size_bS);

  // Allocate memory to save the result in another array of 64-bit variables

  for (int i = 0; i < padding; i++) x[i] = 0; 
  
  long long tmp  = a.get_mpf_t()->_mp_d[size - 1];
  x[padding] = getBitsFromOneLong(tmp, 0, ownLimbSize - padBitOffset);
  
  // Add all the elements in mpf_class to the result
  for (int i = padding + 1; i < sizeOfArray - 1; i++) {
    int leftGmpLimb  = size - 1 - (((i - padding) * ownLimbSize - padBitOffset) / INT64L);
    int leftBit      = ((i - padding) * ownLimbSize - padBitOffset) % INT64L;
    int rightGmpLimb = size - 1 - (((i - padding + 1) * ownLimbSize - padBitOffset) / INT64L);
    int rightBit     = ((i - padding + 1) * ownLimbSize - padBitOffset) % INT64L;
    // If true it means that all the bits are in the same limb. If flase it means that all the 
    // bits are in consecutive limbs.
    if (leftGmpLimb == rightGmpLimb) {
      long long tmp  = a.get_mpf_t()->_mp_d[leftGmpLimb];
      x[i] = getBitsFromOneLong(tmp, leftBit, rightBit);
    } else {
      long long tmpA = a.get_mpf_t()->_mp_d[leftGmpLimb];
      long long tmpB = a.get_mpf_t()->_mp_d[rightGmpLimb];
      x[i] = getBitsFromTwoLong(tmpA, tmpB, leftBit, rightBit);
    }
  }
  int leftBit = ((sizeOfArray - padding - 1) * ownLimbSize + padBitOffset) % INT64L;
  tmp = a.get_mpf_t()->_mp_d[0];
  x[sizeOfArray - 1] = getBitsFromOneLong(tmp, leftBit, INT64L);

  // TODO: Multiply longs by overall sign
}

// THIS HAS NOT BEEN TESTED YET
// TODO: decouple memory allocation from calculation eventually

void generateLongMatrixFromGMPMatrix(const mpf_class *a, const int nr_rows, const int nr_cols, long long **&x,  int &sizeOfArray, int &exp, const int ownLimbSize) {
  // Allocate memory for pointers that point to each element in matrix and to the array 
  // that gives the number of own limbs for each matrix element
  long long **tmpX;
