several improvements for issue #325