simplify decode_memo
comment on error classes