rlewExpand tag (lo:hi:xs) = if lo == tagLo && hi == tagHi
                               then (concat $ replicate cnt val) ++ rlewExpand tag (drop 4 xs)
                               else lo : hi : rlewExpand tag xs
  where
    (tagHi, tagLo) = encodeWord16le tag
    [cntLo, cntHi] = take 2 xs
    cnt = bytesToInt [cntLo, cntHi, 0, 0]
    val = take 2 $ drop 2 xs
rlewExpand tag (lo:hi:xs) = if lo == tagLo && hi == tagHi
                               then (concat $ replicate cnt val) ++ rlewExpand tag (drop 4 xs)
                               else lo : hi : rlewExpand tag xs
  where
    (tagHi, tagLo) = encodeWord16le tag
    [cntLo, cntHi] = take 2 xs
    cnt = bytesToInt [cntLo, cntHi, 0, 0]
    val = take 2 $ drop 2 xs
rlewExpand tag (lo:hi:xs) = if lo == tagLo && hi == tagHi
                               then (concat $ replicate cnt val) ++ rlewExpand tag (drop 4 xs)
                               else lo : hi : rlewExpand tag xs
  where
    (tagHi, tagLo) = encodeWord16le tag
    [cntLo, cntHi] = take 2 xs
    cnt = bytesToInt [cntLo, cntHi, 0, 0]
    val = take 2 $ drop 2 xs