Added stack persistence and recovery