Added the solution mentioned in patch #3125
Changed first approach to a more general MS-specific approach.
Suggested by @SpecLad
Merge pull request #1148 from StevenPuttemans:patch_3125