Re-applied Mantis #3734 to resolve conflicts (did not amend to last commit by accident)