Applied modified code from patch 13459:
More efficient SPWebConfigModification changes: Sometimes the changes were not applied because repeating changes are blocked. Now if there old changes by this solution they are removed first and then the new ones are added.
project by BramNuyts
patch by maxmelcherAlso built a 2013 version with the v4 framework