Still not the best error handling, but better than what I had before.