Cleanup of objective function in preparation for weights. No changes in results