Update smooth code to use templates - doesn't yet dispatch consistently except for doubles, however