Added grids; slightly changed plotting algorithm