added endScene cleanup code