Patch for issue #303 (thanks to @eltjpm)