fix a encode/decode bug, fix some warning