Cleaned up some code, and flushed out the error handler.