further improvements for issue #585