Applied fix from trunk for revision: 1611321 === This reverts most of the changes committed in rev.951013 for OFBIZ-3802 because they caused a few issues as reported in the same Jira ticket.