Code cleanup.
Fix serial receive not working after resuming from sleep. Improve serial reliability. Code cleanup.