Major cleanup of the derivitive functions