Added more exceptions. Improved exception handling.