added linkbag decoding and slice encoding