fix ID references, fix WG element, fix AREA element, remove unneeded empty elements