candidate implementation of  #19 ready to test on UNIX