Exception handling and minor changes