Fixed integration problem.

The function works, in the grand scheme, and is ready to be merged with
the original.