Tweaked and commented lighting algo