Fix TypeError when fx becomes exactly 0, made parsing more robust
Add grid search