Rotation optimized (time /4) and code refactored
Fixed merge