Fixed problem with custom derivatives