Fixing indexing issue, adding shutdown counter.