fix expandMacros off by one error add namespaces