fixed several crashes.