Robustify Pi handling