Data passed to snippet is concatenated for every call

I am creating a map that contains spots, where the user can view some information by clicking them. I am using a route for the spots to get their content:

[
    'pattern' => '/spots/(:any)',
    'action' => function($uid) {
      return snippet('spot', ['data' => page('spots/' . $uid)], true);
    }
  ]

I am setting the last argument to snippet to true, to get the rendered HTML.
The snippet is rendered inside the same overlay box, that has its content replaced on every spot visit.
The snippet’s code:

<?php
  $image = $data->content()->image();
?>

<div>
  <header>
    <img src="<?= e($image->isNotEmpty(), $image->toFile()->url()) ?>" alt="">
    <h1><?= $data->title() ?></h1>
  </header>

  <div class="content">
    <?= $data->content()->content()->kirbytext() ?>
  </div>
</div>

The problem is that for every spot visit, the $data passed to the snippet seem to be concatenated. If after visiting some spots, I do a dump($image) inside the snippet, I am getting something like that:

Kirby\Cms\Field Object
(
    [image] => image1.jpg
)

Kirby\Cms\Field Object
(
    [image] => image2.jpg
)

Kirby\Cms\Field Object
(
    [image] => image3.jpg
)

This does not affect the spot’s rendering, but if for example an image field is empty, I get an 500 server error.

In regards to the 500 error, I think the snippet should be something like this:

<div>
  <header>
    <?php if($image = $data->content()->image()->toFile()): ?>
      <img src="<?= $image->url()) ?>" alt="">
    <?php endif; ?>
    <h1><?= $data->title() ?></h1>
  </header>

  <div class="content">
    <?= $data->content()->content()->kirbytext() ?>
  </div>
</div>

if $data->content()->image() is empty or points to a non existing file, ->toFile() will return null, and in that case you would be running the equivalent of (null)->url(); therefore the error.

In regards to the concatenation, I didn’t really understand what happens where.

Thanks @rasteiner. The concatenation thing was probably not a real problem, it seemed like one because each dump() was adding its log to the overlay box.