Removed numberOfIntervals assignment.

This is not needed for these examples.
Added more checks for the derivative implementation.

This is for #21.