Fix for flatten method

Flatten was broken because of generics as it can be an array of array which is not of type T