Split template functions into another file

Better organization.