Improved error handling during initialization