Fix for mysterious swapping derivatives