Added try/catch blocks.