FIX (from Justin Bayer): avoid memory segfault when pca_d is choosen too big.
a bit more structure.
Cleaning up.