Cleanup of derivative logic
more strict unittests for CustomFunction