Added more try/except blocks.