add packet length check, update autorecovery