[WIP] Fixed bugs with macros

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature? | no
| BC breaks? | maybe
| New docs?     | no
| Tests pass?   | yes
| Fixed tickets | #1157 #1207 #1212
| License | MIT