Fix reset and save stack handling