Style fixes to chat code, and moved packet reading to main thread to fix synchronization issues.