Finished the first draft of the lighting engine and fixed a longstanding bug