several fixes for speedup in pca