Fixing "invalid size" bug
Finally fixing encoding bug