Implemented more exceptions for better error handling.