math clean up patches in preparation for new implementations.