Fix #496
fix macro parsing

Revised approach to parsing the macros. This time we find all potential
macro instances and weed out the ones that are not macros. The regex
expressions work better with this approach.
Merge remote-tracking branch 'origin/master' into 1.4.6