Change some global functions to modules