Reformat functions to more portable form