These two function calls live on their own down here and are easy to miss, they should be moved up before checkAndEmit