cleanup macros and reduce code duplication

2 jobs for macrocleanup