Import StringIO.
Initialize _point_count and _cell_count to None.
Rename dir variable to directory.
Changed format keyword to fmt.