Fixed connection issues... again.
Fixed infinite loop when casting a spell with random targetting.
Refactoring #2