Reimplementation of error handling. README modified