Updated error handling and improved graph functionality