fixes issue #993 and #988