(1) Added T2 logic. (2) Integrated w_mem. (3) Fixed syntax errors.