fixed threading code, server still broken