Added a more robust debugging framework. Found the problem with the curv and grad interpolations. Running now without error. Check next.