Fixed a wrong restrict and declare variables const whereever possible