Fix off by one error and extract TaskStorage interface