PCA rebase and fixes to format testing

This is a rebase of Samira's PCA pull request. I also had to fix some problems with the format testing that I encountered while making sure my rebase was clean.