merged updated light generator and switch syncing code