Rewritten a lot of macros as library functions.