Added error checking on network calls.