Fixed more stargate-related crashes.
The code should be pretty bug-free now.