Made some improvements for issue #45