Remove duplicated recursive call
Remove unused code
Remove duplicated io check
Io should always be valid
Use pow and clamp
Remove copy-paste