Fixes: ACE-2000, reverses fixes for ACE-1297 and ALF-19161 and implements them in a more robust way.

git-svn-id: https://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root@73679 7033f55c-6c29-4ad8-afba-765cb616e738