Simplify read,write_rectangle (still buggy)