Improve error checking during initialization