Add more error information and exception handling