Implemented basic error handling.