Templates instead of functions

"Macro" functions converted to templates to avoid the need to compile the bindings