Apply changes from alain91 for Issue #50