Explicitly check array length

Keeps it consistent with other checks in this file
Remove unused variable
Remove unused variable