Merged autorotate

Added autorotate function and fixed coding styles