diff --git a/src/feature_creation/feature_space/FeatureSpace.cpp b/src/feature_creation/feature_space/FeatureSpace.cpp
index 76d216bb279b1bf14ce09ef5b447350aea83dbf8..8d8a9ddb496d4fc2d3a322b38ca80ac424a7c67c 100644
--- a/src/feature_creation/feature_space/FeatureSpace.cpp
+++ b/src/feature_creation/feature_space/FeatureSpace.cpp
@@ -28,6 +28,7 @@ FeatureSpace::FeatureSpace(
     int n_sis_select,
     int max_store_rung,
     int n_rung_generate,
+    int max_temp_store,
     double min_abs_feat_val,
     double max_abs_feat_val
 ):
@@ -46,8 +47,11 @@ FeatureSpace::FeatureSpace(
     _n_samp(phi_0[0]->n_samp()),
     _n_feat(phi_0.size()),
     _n_rung_store(max_store_rung),
-    _n_rung_generate(n_rung_generate)
+    _n_rung_generate(n_rung_generate),
+    _max_temp_store(max_temp_store)
 {
+    if(_max_temp_store != -1)
+        _max_temp_store /= 3;
     _project = project_funcs::project_r;
 
     if(_n_rung_generate > 1)
@@ -203,7 +207,10 @@ void FeatureSpace::generate_feature_space(std::vector<double>& prop)
             if(nn <= _n_rung_store)
             {
                 bool use_temp = (nn != _max_phi) || (_max_phi > _n_rung_store);
-                node_value_arrs::resize_values_arr(nn, _phi.size(), use_temp);
+                if(_max_temp_store == -1)
+                    node_value_arrs::resize_values_arr(_n_rung_store, _phi.size(), _phi.size(), use_temp);
+                else
+                    node_value_arrs::resize_values_arr(_n_rung_store, _phi.size(), _max_temp_store, use_temp);
                 for(int ff = _start_gen[0]; ff < _phi.size(); ++ff)
                 {
                     _phi[ff]->set_value();
@@ -318,7 +325,10 @@ void FeatureSpace::generate_feature_space(std::vector<double>& prop)
             if(_max_phi <= _n_rung_store)
             {
                 bool use_temp = (_max_phi > _n_rung_store);
-                node_value_arrs::resize_values_arr(_n_rung_store, _phi.size(), use_temp);
+                if(_max_temp_store == -1)
+                    node_value_arrs::resize_values_arr(_n_rung_store, _phi.size(), _phi.size(), use_temp);
+                else
+                    node_value_arrs::resize_values_arr(_n_rung_store, _phi.size(), _max_temp_store, use_temp);
             }
             for(int ff = _start_gen.back(); ff < _phi.size(); ++ff)
             {
diff --git a/src/feature_creation/feature_space/FeatureSpace.hpp b/src/feature_creation/feature_space/FeatureSpace.hpp
index c8808e66643c805d991217d3de6f6f8527640736..d59fab2532588312bd58fdf58155e94226c77f24 100644
--- a/src/feature_creation/feature_space/FeatureSpace.hpp
+++ b/src/feature_creation/feature_space/FeatureSpace.hpp
@@ -48,7 +48,7 @@ class FeatureSpace
     int _n_feat; //!< Total number of features
     int _n_rung_store; //!< Total rungs stored
     int _n_rung_generate; //!< Total number of rungs to generate on the fly
-
+    int _max_temp_store; //!< Maximum number of features to store in temporary storage
 public:
 
     /**
@@ -71,6 +71,7 @@ public:
         int n_sis_select=1,
         int max_store_rung=2,
         int n_rung_generate=0,
+        int max_temp_store=-1,
         double min_abs_feat_val=1e-50,
         double max_abs_feat_val=1e50
     );
diff --git a/src/feature_creation/node/value_storage/nodes_value_containers.cpp b/src/feature_creation/node/value_storage/nodes_value_containers.cpp
index 11664d6b0718329cc45ebbeef134c8022f186d96..f5f289c0101cdc47771f197fb8cb34ff232e18da 100644
--- a/src/feature_creation/node/value_storage/nodes_value_containers.cpp
+++ b/src/feature_creation/node/value_storage/nodes_value_containers.cpp
@@ -3,6 +3,7 @@
 int node_value_arrs::N_SELECTED;
 int node_value_arrs::N_SAMPLES;
 int node_value_arrs::N_STORE_FEATURES;
+int node_value_arrs::N_TEMP_STORE_FEATURES;
 int node_value_arrs::N_RUNGS_STORED;
 int node_value_arrs::N_SAMPLES_TEST;
 
@@ -62,21 +63,23 @@ void node_value_arrs::initialize_values_arr(int n_samples, int n_samples_test, i
     N_SAMPLES_TEST = n_samples_test;
     N_RUNGS_STORED = 0;
     N_STORE_FEATURES = n_primary_feat;
+    N_TEMP_STORE_FEATURES = n_primary_feat;
 
-    VALUES_ARR = std::vector<double>(N_STORE_FEATURES * N_SAMPLES);
-    TEST_VALUES_ARR = std::vector<double>(N_STORE_FEATURES * N_SAMPLES_TEST);
+    VALUES_ARR = std::vector<double>(N_TEMP_STORE_FEATURES * N_SAMPLES);
+    TEST_VALUES_ARR = std::vector<double>(N_TEMP_STORE_FEATURES * N_SAMPLES_TEST);
 
-    TEMP_STORAGE_ARR = std::vector<double>(3 * N_STORE_FEATURES * N_SAMPLES);
-    TEMP_STORAGE_REG = std::vector<int>(3 * N_STORE_FEATURES, -1);
+    TEMP_STORAGE_ARR = std::vector<double>(3 * N_TEMP_STORE_FEATURES * N_SAMPLES);
+    TEMP_STORAGE_REG = std::vector<int>(3 * N_TEMP_STORE_FEATURES, -1);
 
-    TEMP_STORAGE_TEST_ARR = std::vector<double>(3 * N_STORE_FEATURES * N_SAMPLES_TEST);
-    TEMP_STORAGE_TEST_REG = std::vector<int>(3 * N_STORE_FEATURES, -1);
+    TEMP_STORAGE_TEST_ARR = std::vector<double>(3 * N_TEMP_STORE_FEATURES * N_SAMPLES_TEST);
+    TEMP_STORAGE_TEST_REG = std::vector<int>(3 * N_TEMP_STORE_FEATURES, -1);
 }
 
-void node_value_arrs::resize_values_arr(int n_dims, int n_feat, bool use_temp)
+void node_value_arrs::resize_values_arr(int n_dims, int n_feat, int max_temp_store, bool use_temp)
 {
     N_RUNGS_STORED = n_dims;
     N_STORE_FEATURES = n_feat;
+    N_TEMP_STORE_FEATURES = std::min(n_feat, max_temp_store);
 
     VALUES_ARR.resize(N_STORE_FEATURES * N_SAMPLES);
     VALUES_ARR.shrink_to_fit();
@@ -86,16 +89,16 @@ void node_value_arrs::resize_values_arr(int n_dims, int n_feat, bool use_temp)
 
     if(use_temp)
     {
-        TEMP_STORAGE_ARR.resize(3 * N_STORE_FEATURES * N_SAMPLES);
+        TEMP_STORAGE_ARR.resize(3 * N_TEMP_STORE_FEATURES * N_SAMPLES);
         TEMP_STORAGE_ARR.shrink_to_fit();
 
-        TEMP_STORAGE_REG.resize(3 * N_STORE_FEATURES, - 1);
+        TEMP_STORAGE_REG.resize(3 * N_TEMP_STORE_FEATURES, - 1);
         TEMP_STORAGE_REG.shrink_to_fit();
 
-        TEMP_STORAGE_TEST_ARR.resize(3 * N_STORE_FEATURES * N_SAMPLES_TEST);
+        TEMP_STORAGE_TEST_ARR.resize(3 * N_TEMP_STORE_FEATURES * N_SAMPLES_TEST);
         TEMP_STORAGE_TEST_ARR.shrink_to_fit();
 
-        TEMP_STORAGE_TEST_REG.resize(3 * N_STORE_FEATURES, - 1);
+        TEMP_STORAGE_TEST_REG.resize(3 * N_TEMP_STORE_FEATURES, - 1);
         TEMP_STORAGE_TEST_REG.shrink_to_fit();
     }
     else
@@ -109,16 +112,18 @@ double* node_value_arrs::get_value_ptr(int arr_ind, int feat_ind, int offset)
 {
     if(arr_ind < N_STORE_FEATURES)
         return  access_value_arr(arr_ind);
+
     temp_storage_reg(arr_ind, offset) = feat_ind;
-    return access_temp_storage((arr_ind % N_STORE_FEATURES) + (offset % 3) * N_STORE_FEATURES);
+    return access_temp_storage((arr_ind % N_TEMP_STORE_FEATURES) + (offset % 3) * N_TEMP_STORE_FEATURES);
 }
 
 double* node_value_arrs::get_test_value_ptr(int arr_ind, int feat_ind, int offset)
 {
     if(arr_ind < N_STORE_FEATURES)
         return  access_test_value_arr(arr_ind);
+
     temp_storage_test_reg(arr_ind, offset) = feat_ind;
-    return access_temp_storage_test((arr_ind % N_STORE_FEATURES) + (offset % 3) * N_STORE_FEATURES);
+    return access_temp_storage_test((arr_ind % N_TEMP_STORE_FEATURES) + (offset % 3) * N_TEMP_STORE_FEATURES);
 }
 
 void node_value_arrs::initialize_d_matrix_arr()
diff --git a/src/feature_creation/node/value_storage/nodes_value_containers.hpp b/src/feature_creation/node/value_storage/nodes_value_containers.hpp
index dcf657c4c4783fc2b0365797e018316a91bfa9aa..0fbb0d40df0610f83b2a720a2a8c4fa18b12131a 100644
--- a/src/feature_creation/node/value_storage/nodes_value_containers.hpp
+++ b/src/feature_creation/node/value_storage/nodes_value_containers.hpp
@@ -21,6 +21,7 @@ namespace node_value_arrs
     extern int N_SAMPLES; //!< Number of samples in the nodes
     extern int N_SAMPLES_TEST; //!< Number of samples in the nodes
     extern int N_STORE_FEATURES; //!< Number of features with stored values
+    extern int N_TEMP_STORE_FEATURES; //!< Number of feature that can be stored in TEMP_STORAGE ARRs values
     extern int N_RUNGS_STORED; //!< Number of rungs with values stored
 
 
@@ -62,7 +63,7 @@ namespace node_value_arrs
      * @param n_feat number of features to store
      * @param use_temp If true keep the temporary_storage
      */
-    void resize_values_arr(int n_dims, int n_feat, bool use_temp);
+    void resize_values_arr(int n_dims, int n_feat, int max_temp_store, bool use_temp);
 
     /**
      * @brief set of the value arrays
@@ -89,7 +90,7 @@ namespace node_value_arrs
      *
      * @return The register element for a given feature index and offset
      */
-    inline int& temp_storage_reg(int ind, int offset = 0){return TEMP_STORAGE_REG[(ind % N_STORE_FEATURES) + (offset % 3) * N_STORE_FEATURES];}
+    inline int& temp_storage_reg(int ind, int offset = 0){return TEMP_STORAGE_REG[(ind % N_TEMP_STORE_FEATURES) + (offset % 3) * N_TEMP_STORE_FEATURES];}
 
     /**
      * @brief Get a reference slot/feature test register
@@ -99,7 +100,7 @@ namespace node_value_arrs
      *
      * @return The register element for a given feature index and offset
      */
-    inline int& temp_storage_test_reg(int ind, int offset = 0){return TEMP_STORAGE_TEST_REG[(ind % N_STORE_FEATURES) + (offset % 3) * N_STORE_FEATURES];}
+    inline int& temp_storage_test_reg(int ind, int offset = 0){return TEMP_STORAGE_TEST_REG[(ind % N_TEMP_STORE_FEATURES) + (offset % 3) * N_TEMP_STORE_FEATURES];}
 
     /**
      * @brief Access element of the permanent storage array
diff --git a/src/inputs/InputParser.cpp b/src/inputs/InputParser.cpp
index c444ac2eb5cbd50b440f67bc34362beac71037d6..8822bbda6657c8ca99b5f84472afe6af6e0998b6 100644
--- a/src/inputs/InputParser.cpp
+++ b/src/inputs/InputParser.cpp
@@ -14,7 +14,8 @@ InputParser::InputParser(boost::property_tree::ptree IP, std::string fn, std::sh
     _max_store_rung(IP.get<int>("n_rung_store", _max_rung - 1)),
     _n_rung_generate(IP.get<int>("n_rung_generate", 0)),
     _n_samp(0),
-    _n_residuals(IP.get<int>("n_residual", 1))
+    _n_residuals(IP.get<int>("n_residual", 1)),
+    _max_temp_store(IP.get<int>("max_temp_storage", -1))
 {
     std::ifstream data_stream;
     std::string line;
@@ -268,7 +269,7 @@ void InputParser::generate_feature_space(std::shared_ptr<MPI_Interface> comm, st
     for(int ff = 0; ff < headers.size(); ++ff)
         phi_0.push_back(std::make_shared<FeatureNode>(ff, headers[ff], data[ff], test_data[ff], units[ff]));
 
-    _feat_space = std::make_shared<FeatureSpace>(comm, phi_0, _opset, _prop_train, _task_sizes_train, _max_rung, _n_sis_select, _max_store_rung, _n_rung_generate, _l_bound, _u_bound);
+    _feat_space = std::make_shared<FeatureSpace>(comm, phi_0, _opset, _prop_train, _task_sizes_train, _max_rung, _n_sis_select, _max_store_rung, _n_rung_generate, _max_temp_store, _l_bound, _u_bound);
 }
 
 void stripComments(std::string& filename)
diff --git a/src/inputs/InputParser.hpp b/src/inputs/InputParser.hpp
index 32c4e3b2254dae84554b72af5610cf01d5f471d3..aaa8f354585c64eb3555e213b466d460e9b49edd 100644
--- a/src/inputs/InputParser.hpp
+++ b/src/inputs/InputParser.hpp
@@ -50,6 +50,7 @@ public:
     int _n_sis_select;
     int _n_samp;
     int _n_residuals;
+    int _max_temp_store; //!< Maximum number of features to store in temporary storage
 
     InputParser(boost::property_tree::ptree IP, std::string fn, std::shared_ptr<MPI_Interface> comm);
     inline std::shared_ptr<FeatureSpace> feat_space(){return _feat_space;}