Improved merge pull request #496 from Moc