Added assertions for 4d arrays
Added debug clause for good measure