Fix errors introduced by not understanding code.

From #6323.

Since the diff is unreadable, here's the actual changes. 

* Reverse early return, because we need the $vsite variable later.
* Change references to $space to $vsite