Improve http status detection. Clean up debug logging.