Fixed grid search bugs