Refactor code of "Tricks of the 3D Game Programming Gurus"