Added more try-catch blocks to fix some crashes