Fix server memory leaks