Move nmem_reset up to beginning of loop, as it is a pre-condition.