Fixes a bug in encoding.