Fixes issue #78 and #240.