Added checks for array bounds and metadata.