improved rotation script and added toggable config parameter auto_rotate