Fixed bug related to light sources outside bounds

This reverts commit 1a1b2f7546eef1abec4647771aa1ef66c142a93c.