Removes profiling code and handles http failures by retrying.