Move function templates to header files