Fixed the bug that caused only the last rule to be applied to the lights.