Updated the chains library to handle errors a bit differently and some other minor changes