Fixed minor bugs and two crashes.