Continue refactory, add rotation code