Fixed some possible NPE in MageServerImpl (Fixes #342).