WPS4R fixes and improvements

This pull request contains @MatthiasHinz final improvements to the WPS4R codebase.