Cleanup some template functions

Separate the functionality into there own class

@tanghus @DeepDiver1975 @MTGap @Raydiation @zimba12