Catching more exceptions; other minor improvements