some more work on PCA including bug fixes