REG_FUNC macros

And some auxiliary changes