/* A namespace for all of the Statistics */
 namespace Stats {
 
+struct StorageParams
+{
+    virtual ~StorageParams();
+};
 
 //////////////////////////////////////////////////////////////////////
 //
      * A unique stat ID for each stat in the simulator.
      * Can be used externally for lookups as well as for debugging.
      */
+    static int id_count;
     int id;
 
+  public:
+    const StorageParams *storageParams;
+
   public:
     Info();
     virtual ~Info();
     Counter squares;
     Counter samples;
 
-    Counter min;
-    Counter max;
-    Counter bucket_size;
-    size_type size;
     bool fancy;
 };
 
     /** Set up an info class for this statistic */
     void setInfo(Info *info);
     /** Save Storage class parameters if any */
+    void setParams(const StorageParams *params);
+    /** Save Storage class parameters if any */
     void setInit();
 
+    /** Grab the information class for this statistic */
     Info *info();
+    /** Grab the information class for this statistic */
     const Info *info() const;
 };
 
  */
 class StatStor
 {
-  public:
-    /** The paramaters for this storage type, none for a scalar. */
-    struct Params { };
-
   private:
     /** The statistic value. */
     Counter data;
 
+  public:
+    struct Params : public StorageParams {};
+
   public:
     /**
      * Builds this storage element and calls the base constructor of the
      * datatype.
      */
-    StatStor(const Params &) : data(Counter()) {}
+    StatStor(Info *info)
+        : data(Counter())
+    { }
 
     /**
      * The the stat to the given value.
      * @param val The new value.
-     * @param p The paramters of this storage type.
      */
-    void set(Counter val, const Params &p) { data = val; }
+    void set(Counter val) { data = val; }
     /**
      * Increment the stat by the given value.
      * @param val The new value.
-     * @param p The paramters of this storage type.
      */
-    void inc(Counter val, const Params &p) { data += val; }
+    void inc(Counter val) { data += val; }
     /**
      * Decrement the stat by the given value.
      * @param val The new value.
-     * @param p The paramters of this storage type.
      */
-    void dec(Counter val, const Params &p) { data -= val; }
+    void dec(Counter val) { data -= val; }
     /**
      * Return the value of this stat as its base type.
-     * @param p The params of this storage type.
      * @return The value of this stat.
      */
-    Counter value(const Params &p) const { return data; }
+    Counter value() const { return data; }
     /**
      * Return the value of this stat as a result type.
-     * @param p The parameters of this storage type.
      * @return The value of this stat.
      */
-    Result result(const Params &p) const { return (Result)data; }
+    Result result() const { return (Result)data; }
     /**
      * Reset stat value to default
      */
-    void reset() { data = Counter(); }
+    void reset(Info *info) { data = Counter(); }
 
     /**
      * @return true if zero value
  */
 class AvgStor
 {
-  public:
-    /** The paramaters for this storage type */
-    struct Params { };
-
   private:
     /** The current count. */
     Counter current;
     /** The tick that current last changed. */
     mutable Tick last;
 
+  public:
+    struct Params : public StorageParams {};
+
   public:
     /**
      * Build and initializes this stat storage.
      */
-    AvgStor(Params &p) : current(0), total(0), last(0) { }
+    AvgStor(Info *info)
+        : current(0), total(0), last(0)
+    { }
 
     /**
      * Set the current count to the one provided, update the total and last
      * set values.
      * @param val The new count.
-     * @param p The parameters for this storage.
      */
     void
-    set(Counter val, Params &p)
+    set(Counter val)
     {
         total += current * (curTick - last);
         last = curTick;
     /**
      * Increment the current count by the provided value, calls set.
      * @param val The amount to increment.
-     * @param p The parameters for this storage.
      */
-    void inc(Counter val, Params &p) { set(current + val, p); }
+    void inc(Counter val) { set(current + val); }
 
     /**
      * Deccrement the current count by the provided value, calls set.
      * @param val The amount to decrement.
-     * @param p The parameters for this storage.
      */
-    void dec(Counter val, Params &p) { set(current - val, p); }
+    void dec(Counter val) { set(current - val); }
 
     /**
      * Return the current count.
-     * @param p The parameters for this storage.
      * @return The current count.
      */
-    Counter value(const Params &p) const { return current; }
+    Counter value() const { return current; }
 
     /**
      * Return the current average.
-     * @param p The parameters for this storage.
      * @return The current average.
      */
     Result
-    result(const Params &p) const
+    result() const
     {
         total += current * (curTick - last);
         last = curTick;
      * Reset stat value to default
      */
     void
-    reset()
+    reset(Info *info)
     {
         total = 0;
         last = curTick;
 {
   public:
     typedef Stor Storage;
-
-    /** Define the params of the storage class. */
-    typedef typename Storage::Params Params;
+    typedef typename Stor::Params Params;
 
   protected:
     /** The storage of this stat. */
     char storage[sizeof(Storage)] __attribute__ ((aligned (8)));
 
-    /** The parameters for this stat. */
-    Params params;
-
   protected:
     /**
      * Retrieve the storage.
     void
     doInit()
     {
-        new (storage) Storage(params);
+        new (storage) Storage(info());
         setInit();
     }
 
      * Return the current value of this stat as its base type.
      * @return The current value.
      */
-    Counter value() const { return data()->value(params); }
+    Counter value() const { return data()->value(); }
 
   public:
-    /**
-     * Create and initialize this stat, register it with the database.
-     */
-    ScalarBase()
-    { }
+    ScalarBase() { }
 
   public:
     // Common operators for stats
      * Increment the stat by 1. This calls the associated storage object inc
      * function.
      */
-    void operator++() { data()->inc(1, params); }
+    void operator++() { data()->inc(1); }
     /**
      * Decrement the stat by 1. This calls the associated storage object dec
      * function.
      */
-    void operator--() { data()->dec(1, params); }
+    void operator--() { data()->dec(1); }
 
     /** Increment the stat by 1. */
     void operator++(int) { ++*this; }
      * @param v The new value.
      */
     template <typename U>
-    void operator=(const U &v) { data()->set(v, params); }
+    void operator=(const U &v) { data()->set(v); }
 
     /**
      * Increment the stat by the given value. This calls the associated
      * @param v The value to add.
      */
     template <typename U>
-    void operator+=(const U &v) { data()->inc(v, params); }
+    void operator+=(const U &v) { data()->inc(v); }
 
     /**
      * Decrement the stat by the given value. This calls the associated
      * @param v The value to substract.
      */
     template <typename U>
-    void operator-=(const U &v) { data()->dec(v, params); }
+    void operator-=(const U &v) { data()->dec(v); }
 
     /**
      * Return the number of elements, always 1 for a scalar.
     /**
      * Reset stat value to default
      */
-    void reset() { data()->reset(); }
+    void reset() { data()->reset(info()); }
 
-    Counter value() { return data()->value(params); }
+    Counter value() { return data()->value(); }
 
-    Result result() { return data()->result(params); }
+    Result result() { return data()->result(); }
 
     Result total() { return result(); }
 
      * Return the current value of this stat as its base type.
      * @return The current value.
      */
-    Counter value() const { return stat->data(index)->value(stat->params); }
+    Counter value() const { return stat->data(index)->value(); }
 
     /**
      * Return the current value of this statas a result type.
      * @return The current value.
      */
-    Result result() const { return stat->data(index)->result(stat->params); }
+    Result result() const { return stat->data(index)->result(); }
 
   public:
     /**
      * Create and initialize this proxy, do not register it with the database.
-     * @param p The params to use.
      * @param i The index to access.
      */
     ScalarProxy(Stat *s, off_type i)
      * Increment the stat by 1. This calls the associated storage object inc
      * function.
      */
-    void operator++() { stat->data(index)->inc(1, stat->params); }
+    void operator++() { stat->data(index)->inc(1); }
     /**
      * Decrement the stat by 1. This calls the associated storage object dec
      * function.
      */
-    void operator--() { stat->data(index)->dec(1, stat->params); }
+    void operator--() { stat->data(index)->dec(1); }
 
     /** Increment the stat by 1. */
     void operator++(int) { ++*this; }
     void
     operator=(const U &v)
     {
-        stat->data(index)->set(v, stat->params);
+        stat->data(index)->set(v);
     }
 
     /**
     void
     operator+=(const U &v)
     {
-        stat->data(index)->inc(v, stat->params);
+        stat->data(index)->inc(v);
     }
 
     /**
     void
     operator-=(const U &v)
     {
-        stat->data(index)->dec(v, stat->params);
+        stat->data(index)->dec(v);
     }
 
     /**
 {
   public:
     typedef Stor Storage;
-
-    /** Define the params of the storage class. */
-    typedef typename Storage::Params Params;
+    typedef typename Stor::Params Params;
 
     /** Proxy type */
     typedef ScalarProxy<VectorBase<Storage> > Proxy;
     Storage *storage;
     size_type _size;
 
-    /** The parameters for this stat. */
-    Params params;
-
   protected:
     /**
      * Retrieve the storage.
         storage = reinterpret_cast<Storage *>(ptr);
 
         for (off_type i = 0; i < _size; ++i)
-            new (&storage[i]) Storage(params);
+            new (&storage[i]) Storage(info());
 
         setInit();
     }
     {
         vec.resize(size());
         for (off_type i = 0; i < size(); ++i)
-            vec[i] = data(i)->value(params);
+            vec[i] = data(i)->value();
     }
 
     /**
     {
         vec.resize(size());
         for (off_type i = 0; i < size(); ++i)
-            vec[i] = data(i)->result(params);
+            vec[i] = data(i)->result();
     }
 
     /**
     {
         Result total = 0.0;
         for (off_type i = 0; i < size(); ++i)
-            total += data(i)->result(params);
+            total += data(i)->result();
         return total;
     }
 
     reset()
     {
         for (off_type i = 0; i < size(); ++i)
-            data(i)->reset();
+            data(i)->reset(info());
     }
 
   public:
         vec.resize(size());
 
         for (off_type i = 0; i < size(); ++i)
-            vec[i] = data(i)->result(stat->params);
+            vec[i] = data(i)->result();
 
         return vec;
     }
     {
         Result total = 0;
         for (off_type i = 0; i < size(); ++i)
-            total += data(i)->result(stat->params);
+            total += data(i)->result();
         return total;
     }
 
 {
   public:
     typedef Stor Storage;
-    typedef typename Storage::Params Params;
+    typedef typename Stor::Params Params;
     typedef VectorProxy<Vector2dBase<Storage> > Proxy;
     friend class ScalarProxy<Vector2dBase<Storage> >;
     friend class VectorProxy<Vector2dBase<Storage> >;
     size_type y;
     size_type _size;
     Storage *storage;
-    Params params;
 
   protected:
     Storage *data(off_type index) { return &storage[index]; }
         storage = reinterpret_cast<Storage *>(ptr);
 
         for (off_type i = 0; i < _size; ++i)
-            new (&storage[i]) Storage(params);
+            new (&storage[i]) Storage(info);
 
         setInit();
     }
     reset()
     {
         for (off_type i = 0; i < size(); ++i)
-            data(i)->reset();
+            data(i)->reset(info());
     }
 
     bool
 {
   public:
     /** The parameters for a distribution stat. */
-    struct Params
+    struct Params : public StorageParams
     {
         /** The minimum value to track. */
         Counter min;
         /** The number of entries in each bucket. */
         Counter bucket_size;
         /** The number of buckets. Equal to (max-min)/bucket_size. */
-        size_type size;
+        size_type buckets;
     };
     enum { fancy = false };
 
   private:
+    /** The minimum value to track. */
+    Counter min_track;
+    /** The maximum value to track. */
+    Counter max_track;
+    /** The number of entries in each bucket. */
+    Counter bucket_size;
+    /** The number of buckets. Equal to (max-min)/bucket_size. */
+    size_type buckets;
+
     /** The smallest value sampled. */
     Counter min_val;
     /** The largest value sampled. */
     VCounter cvec;
 
   public:
-    DistStor(const Params ¶ms)
-        : cvec(params.size)
+    DistStor(Info *info)
+        : cvec(safe_cast<const Params *>(info->storageParams)->buckets)
     {
-        reset();
+        reset(info);
     }
 
     /**
      * @param params The paramters of the distribution.
      */
     void
-    sample(Counter val, int number, const Params ¶ms)
+    sample(Counter val, int number)
     {
-        if (val < params.min)
+        if (val < min_track)
             underflow += number;
-        else if (val > params.max)
+        else if (val > max_track)
             overflow += number;
         else {
             size_type index =
-                (size_type)std::floor((val - params.min) / params.bucket_size);
-            assert(index < size(params));
+                (size_type)std::floor((val - min_track) / bucket_size);
+            assert(index < size());
             cvec[index] += number;
         }
 
     /**
      * Return the number of buckets in this distribution.
      * @return the number of buckets.
-     * @todo Is it faster to return the size from the parameters?
      */
-    size_type size(const Params &) const { return cvec.size(); }
+    size_type size() const { return cvec.size(); }
 
     /**
      * Returns true if any calls to sample have been made.
-     * @param params The paramters of the distribution.
      * @return True if any values have been sampled.
      */
     bool
-    zero(const Params ¶ms) const
+    zero() const
     {
         return samples == Counter();
     }
 
     void
-    update(DistData *data, const Params ¶ms)
+    update(Info *info, DistData &data)
     {
-        data->min = params.min;
-        data->max = params.max;
-        data->bucket_size = params.bucket_size;
-        data->size = params.size;
+        const Params *params = safe_cast<const Params *>(info->storageParams);
 
-        data->min_val = (min_val == CounterLimits::max()) ? 0 : min_val;
-        data->max_val = (max_val == CounterLimits::min()) ? 0 : max_val;
-        data->underflow = underflow;
-        data->overflow = overflow;
-        data->cvec.resize(params.size);
-        for (off_type i = 0; i < params.size; ++i)
-            data->cvec[i] = cvec[i];
+        data.min_val = (min_val == CounterLimits::max()) ? 0 : min_val;
+        data.max_val = (max_val == CounterLimits::min()) ? 0 : max_val;
+        data.underflow = underflow;
+        data.overflow = overflow;
 
-        data->sum = sum;
-        data->squares = squares;
-        data->samples = samples;
+        int buckets = params->buckets;
+        data.cvec.resize(buckets);
+        for (off_type i = 0; i < buckets; ++i)
+            data.cvec[i] = cvec[i];
+
+        data.sum = sum;
+        data.squares = squares;
+        data.samples = samples;
     }
 
     /**
      * Reset stat value to default
      */
     void
-    reset()
+    reset(Info *info)
     {
+        const Params *params = safe_cast<const Params *>(info->storageParams);
+        min_track = params->min;
+        max_track = params->max;
+        bucket_size = params->bucket_size;
+
         min_val = CounterLimits::max();
         max_val = CounterLimits::min();
         underflow = 0;
 class FancyStor
 {
   public:
-    /**
-     * No paramters for this storage.
-     */
-    struct Params {};
+    struct Params : public StorageParams {};
+
+  public:
     enum { fancy = true };
 
   private:
     /**
      * Create and initialize this storage.
      */
-    FancyStor(const Params &)
+    FancyStor(Info *info)
         : sum(Counter()), squares(Counter()), samples(Counter())
     { }
 
      * @param p The parameters of this stat.
      */
     void
-    sample(Counter val, int number, const Params &p)
+    sample(Counter val, int number)
     {
         Counter value = val * number;
         sum += value;
     }
 
     void
-    update(DistData *data, const Params ¶ms)
+    update(Info *info, DistData &data)
     {
-        data->sum = sum;
-        data->squares = squares;
-        data->samples = samples;
+        data.sum = sum;
+        data.squares = squares;
+        data.samples = samples;
     }
 
     /**
      * Return the number of entries in this stat, 1
      * @return 1.
      */
-    size_type size(const Params &) const { return 1; }
+    size_type size() const { return 1; }
 
     /**
      * Return true if no samples have been added.
      * @return True if no samples have been added.
      */
-    bool zero(const Params &) const { return samples == Counter(); }
+    bool zero() const { return samples == Counter(); }
 
     /**
      * Reset stat value to default
      */
     void
-    reset()
+    reset(Info *info)
     {
         sum = Counter();
         squares = Counter();
 class AvgFancy
 {
   public:
-    /** No parameters for this storage. */
-    struct Params {};
+    struct Params : public StorageParams {};
+
+  public:
     enum { fancy = true };
 
   private:
     /**
      * Create and initialize this storage.
      */
-    AvgFancy(const Params &) : sum(Counter()), squares(Counter()) {}
+    AvgFancy(Info *info)
+        : sum(Counter()), squares(Counter())
+    {}
 
     /**
      * Add a value to the distribution for the given number of times.
      * Update the running sum and sum of squares.
      * @param val The value to add.
      * @param number The number of times to add the value.
-     * @param p The paramters of the distribution.
      */
     void
-    sample(Counter val, int number, const Params &p)
+    sample(Counter val, int number)
     {
         Counter value = val * number;
         sum += value;
     }
 
     void
-    update(DistData *data, const Params ¶ms)
+    update(Info *info, DistData &data)
     {
-        data->sum = sum;
-        data->squares = squares;
-        data->samples = curTick;
+        data.sum = sum;
+        data.squares = squares;
+        data.samples = curTick;
     }
 
     /**
      * Return the number of entries, in this case 1.
      * @return 1.
      */
-    size_type size(const Params ¶ms) const { return 1; }
+    size_type size() const { return 1; }
 
     /**
      * Return true if no samples have been added.
      * @return True if the sum is zero.
      */
-    bool zero(const Params ¶ms) const { return sum == Counter(); }
+    bool zero() const { return sum == Counter(); }
 
     /**
      * Reset stat value to default
      */
     void
-    reset()
+    reset(Info *info)
     {
         sum = Counter();
         squares = Counter();
 {
   public:
     typedef Stor Storage;
-    /** Define the params of the storage class. */
-    typedef typename Storage::Params Params;
+    typedef typename Stor::Params Params;
 
   protected:
     /** The storage for this stat. */
     char storage[sizeof(Storage)] __attribute__ ((aligned (8)));
 
-    /** The parameters for this stat. */
-    Params params;
-
   protected:
     /**
      * Retrieve the storage.
     void
     doInit()
     {
-        new (storage) Storage(params);
+        new (storage) Storage(info());
         setInit();
     }
 
      * @param n The number of times to add it, defaults to 1.
      */
     template <typename U>
-    void sample(const U &v, int n = 1) { data()->sample(v, n, params); }
+    void sample(const U &v, int n = 1) { data()->sample(v, n); }
 
     /**
      * Return the number of entries in this stat.
      * @return The number of entries.
      */
-    size_type size() const { return data()->size(params); }
+    size_type size() const { return data()->size(); }
     /**
      * Return true if no samples have been added.
      * @return True if there haven't been any samples.
      */
-    bool zero() const { return data()->zero(params); }
+    bool zero() const { return data()->zero(); }
 
     void
     update(DistInfoBase *base)
     {
         base->data.fancy = Storage::fancy;
-        data()->update(&(base->data), params);
+        data()->update(info(), base->data);
     }
 
     /**
     void
     reset()
     {
-        data()->reset();
+        data()->reset(info());
     }
 
     bool
 {
   public:
     typedef Stor Storage;
-    typedef typename Storage::Params Params;
+    typedef typename Stor::Params Params;
     typedef DistProxy<VectorDistBase<Storage> > Proxy;
     friend class DistProxy<VectorDistBase<Storage> >;
 
   protected:
     Storage *storage;
     size_type _size;
-    Params params;
 
   protected:
     Storage *
         storage = reinterpret_cast<Storage *>(ptr);
 
         for (off_type i = 0; i < _size; ++i)
-            new (&storage[i]) Storage(params);
+            new (&storage[i]) Storage(info());
 
         setInit();
     }
         return false;
 #if 0
         for (off_type i = 0; i < size(); ++i)
-            if (!data(i)->zero(params))
+            if (!data(i)->zero())
                 return false;
         return true;
 #endif
     reset()
     {
         for (off_type i = 0; i < size(); ++i)
-            data(i)->reset();
+            data(i)->reset(info());
     }
 
     bool
         base->data.resize(size);
         for (off_type i = 0; i < size; ++i) {
             base->data[i].fancy = Storage::fancy;
-            data(i)->update(&(base->data[i]), params);
+            data(i)->update(info(), base->data[i]);
         }
     }
 };
     void
     sample(const U &v, int n = 1)
     {
-        data()->sample(v, n, stat->params);
+        data()->sample(v, n);
     }
 
     size_type
     bool
     zero() const
     {
-        return data()->zero(stat->params);
+        return data()->zero();
     }
 
     /**
 {
     Result total = 0;
     for (off_type i = 0; i < x_size(); ++i)
-        total += data(i)->result(stat->params);
+        total += data(i)->result();
 }
 #endif
 
   public:
     /** Base implementation. */
     typedef DistBase<DistStor> Base;
-    /** The Parameter type. */
-    typedef DistStor::Params Params;
 
   public:
     /**
     Distribution &
     init(Counter min, Counter max, Counter bkt)
     {
-        this->params.min = min;
-        this->params.max = max;
-        this->params.bucket_size = bkt;
-        this->params.size = (size_type)rint((max - min) / bkt + 1.0);
+        DistStor::Params *params = new DistStor::Params;
+        params->min = min;
+        params->max = max;
+        params->bucket_size = bkt;
+        params->buckets = (size_type)rint((max - min) / bkt + 1.0);
+        this->setParams(params);
         this->doInit();
         return *this;
     }
   public:
     /** The base implementation */
     typedef DistBase<DistStor> Base;
-    /** The parameter type. */
-    typedef DistStor::Params Params;
 
   public:
     /**
   public:
     /** The base implementation */
     typedef DistBase<DistStor> Base;
-    /** The parameter type. */
-    typedef DistStor::Params Params;
 
   public:
     /**
   public:
     /** The base implementation */
     typedef VectorDistBase<DistStor> Base;
-    /** The parameter type. */
-    typedef DistStor::Params Params;
 
   public:
     /**
     VectorDistribution &
     init(size_type size, Counter min, Counter max, Counter bkt)
     {
-        this->params.min = min;
-        this->params.max = max;
-        this->params.bucket_size = bkt;
-        this->params.size = rint((max - min) / bkt + 1.0);
+        DistStor::Params *params = new DistStor::Params;
+        params->min = min;
+        params->max = max;
+        params->bucket_size = bkt;
+        params->buckets = rint((max - min) / bkt + 1.0);
+        this->setParams(params);
         this->doInit(size);
         return *this;
     }
   public:
     /** The base implementation */
     typedef VectorDistBase<FancyStor> Base;
-    /** The parameter type. */
-    typedef DistStor::Params Params;
 
   public:
     /**
   public:
     /** The base implementation */
     typedef VectorDistBase<AvgFancy> Base;
-    /** The parameter type. */
-    typedef DistStor::Params Params;
 
   public:
     /**