Fix write and toString