Working regeneration, fixed bug storing the weights.