Some changes to fix the crash.