Clean up exception handling and logging