Changed debug info and error handling