Moved getGrid() (WeakReference) to a local var

Moved `gs.getGrid()` to a local variable because it is backed by a `WeakReference`.
If we lose every strong reference, the GC might invalidate it at any point and will cause it to return null. Even if an earlier check for null passed with true.