Removed logging/die statements, swapped  for  so that array_diff stops failing.
Removed max.