OPT: Speed improvements by avoiding repeated calls to check_array