Improve code style

Fix a couple of type names which are not following the coding conventions.
Change some variable names so that they are easier to understand.
Fix substitute variables in macro calls

With the introduction of nested macros in entities (see
commit 6d9d79b6caf250b29cd3bab457d5da68a929962f) it becomes
necessary to substitute variables in the attributes of the
`call-macro` element.