Added the principal transformer

Hi Jamie,

This is ready for your review. I Added the principal transformer we discussed last week. Also added some UTs and updated some documentation.