Better error handling for errors during startup
Moved error handling code where it would actually do some good