Troubleshooting help? WiFi only works when connected to PC

Since DEBUG == True by definition, some how I fear that your

while (!Serial) {
      ;
    }

in the Setup() section has something to do with this, because this procedure is going to block as long it get nothing from serial.

Put a

Serial.println("some thing");

right after it to see if it's where it get stuck