Templated functions and added macro for converts.