Altered the rotation algorithm to be more general, also removed many commented out lines.