Move packet receiving and processing to background thread.
Style fixes.