Try-catch blocks and some cleanup.