Fixed bugs and crashes