fixed bug in PCA reconstruction.
Added a list flatten() function.