fixed memory decoding bugs.