Some improvements for array check by @thbourlove