Fix for issue #39 and updates for issue #87