Revamp encodeType/decodeType