Handle network failures

Close #45 
/cc @alloy