Added some catch blocks to aid with debugging.