Improve handling of different styles
Free grid_buffer when program exits