Fixed undefined variables in attribute maps

Some variables are used before they are defined...