Better error handling with automatic reconnection of slave to master when connection is lost