Making the fix for issue #1165 less hackish and more official