Look inside to see the fixes I added :). I left a comment every time I made a change. Also, I suggest looking at this for further improvements - https://scratch.mit.edu/projects/427365740/ (also a fix I made for somebody) as it contains the fixes to the problems with @geotale's tutorial.
Made for @Megamateions as a fix to their raytracer :)