Cleaned up perform stats code