fix memorization logic;use single rand engine to generate seed for the model;