fix patch bugs/error reporting