backport of 24ee4e0dd729df63873d2e0e22de2aa6e57c8401 from trunk, closes #579
merge 90ca57f3362dc1ee8fc767190b7a7034304ccf1d, refs #579