Fix negative value that introduces a bug on nvidia
Remove some unused code