Implementation for issue #17.