Fixed broken serialization logic.
Now uses slightly more disk space.
Will need to optimize it later.