Light rearrangement and code cleanup