Move server save code to global event