added some testing code and a tweak or two for rotation