This fixes #12 (closed), and is an extraction of the stuff tried to merge with !7 (closed)
mentioned in commit 48b32256
merged