curpos = y * map.width + x;
     if ('~' == map.cells[curpos] &&
         (   (curpos >= map.width && '.' == map.cells[curpos - map.width])
-         || (curpos < map.width * (map.height - 1) && '.' == map.cells[curpos + map.width])
-         || (curpos > 0 && '.' == map.cells[curpos - 1] && curpos % map.width != 0)
-         || (curpos < (map.width * map.height) && '.' == map.cells[curpos + 1] && (curpos + 1) % map.width != 0)))
+         || (curpos < map.width * (map.height-1) && '.' == map.cells[curpos + map.width])
+         || (curpos > 0 && curpos % map.width != 0 && '.' == map.cells[curpos-1])
+         || (curpos < (map.width * map.height) && (curpos+1) % map.width != 0 && '.' == map.cells[curpos+1])))
       map.cells[y * map.width + x] = '.'; }
   return map; }
 
   toggle_window(&win_meta, &win_log);
 
   int key;
-  unsigned char quit_called;
+  unsigned char quit_called = 0;
   if (0 == world.interactive) {
     unsigned char still_reading_file = 1;
     int action;