TODO: Fix array checking.
Never felt so frustrated at such fragile code.