renamed tune to optimize2, use NULL instead of NaN