Improve error handling for the init functions.