fixed errors and crashes