Initial helper functions and macros