New rotation code. One bug where it only uses one of the returned values... not sure why, but investigating