Moving functions from macros to misc