Performance improvements

changed function parameters to use pointers for template discriminators
rather than references. Now entire temporaries that are not used do not
have to be created.