Several more cleanups and a bugfix: missing argument on in_array.