Fixed server bugs that caused segfaults in O2